Create Your Ain App For Fifa Blue Planet Cup

Posted on

Just a funny practise to charge The Official Website of the FIFA World Cup (http://www.fifa.com/) inward a webview.


MainActivity.java

package com.example.myfifa;  import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.webkit.WebView; import android.webkit.WebViewClient;  world shape MainActivity extends Activity {    WebView myBrowser;  someone lastly static String FIFA_HOME = "http://www.fifa.com/";    someone lastly static String KEY_URL = "KEY_URL";   @SuppressLint("SetJavaScriptEnabled")  @Override  protected void onCreate(Bundle savedInstanceState) {   super.onCreate(savedInstanceState);   setContentView(R.layout.activity_main);      //restore url after config/orientation changed   String openUrl = FIFA_HOME;   if (savedInstanceState != null) {    openUrl = savedInstanceState.getString(KEY_URL);   }    myBrowser = (WebView)findViewById(R.id.mybrowser);   myBrowser.getSettings().setJavaScriptEnabled(true);   myBrowser.setWebViewClient(new WebViewClient());   myBrowser.loadUrl(openUrl);   }   @Override  protected void onSaveInstanceState(Bundle outState) {   //save url earlier config/orientation changed   outState.putString(KEY_URL, myBrowser.getUrl());   super.onSaveInstanceState(outState);  }   @Override  world boolean onCreateOptionsMenu(Menu menu) {    // Inflate the menu; this adds items to the activity bar if it is present.   getMenuInflater().inflate(R.menu.main, menu);   supply true;  }   @Override  world boolean onOptionsItemSelected(MenuItem item) {   int id = item.getItemId();   if (id == R.id.action_openinbrowser) {        Uri openUri = Uri.parse(myBrowser.getUrl());    Intent myIntent = novel Intent(Intent.ACTION_VIEW, openUri);    startActivity(myIntent);        supply true;   }   supply super.onOptionsItemSelected(item);  }  } 

activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"     tools:context="com.example.myfifa.MainActivity" >      <TextView         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_horizontal"         android:autoLink="web"         android:text="https://rootandroid.org//"         android:textStyle="bold" />          <WebView         android:id="@+id/mybrowser"         android:layout_width="match_parent"         android:layout_height="match_parent" />  </LinearLayout> 

Modify /res/menu/main.xml to supersede add together option exceptional of action_openinbrowser.

<menu xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     tools:context="com.example.myfifa.MainActivity" >      <item         android:id="@+id/action_openinbrowser"         android:orderInCategory="100"         android:title="Create your ain App for FIFA World Cup"         app:showAsAction="ifRoom|withText"/>  </menu> 

Modify /res/values/strings.xml to add together string resources of “action_openinbrowser”.

<?xml version="1.0" encoding="utf-8"?> <resources>      <string name="app_name">MyFIFA</string>     <string name="hello_world">Hello world!</string>     <string name="action_settings">Settings</string>     <string name="action_openinbrowser">Open inward Browser</string>  </resources> 

uses-permission of “android.permission.INTERNET” is needed inward AndroidManifest.xml.

Just a funny practise to charge The Official Website of the FIFA World Cup  Create your ain App for FIFA World CupDownload the files.

Download too seek the APK.

Next:
– Implement WebChromeClient to think downloaded favicon too championship inward WebView.