Tuesday 15 April 2014

android - How to make a app icon go to website -



android - How to make a app icon go to website -

this question has reply here:

how can open url in android's web browser application? 16 answers

i trying create app website. app pretty basic, want app icon when clicked on users phone go straight website. thought pretty straight forward, having tough time finding on how accomplish this. have found tutorial on http://developer.android.com/guide/webapps/webview.html , implemented , works. not want go webview. go straight native phone browser when clicked. explain in detail how accomplish please.

for sake of reply should not create kind of application.

first of create android project, in create android xml file in layout folder.

name mywebview.xml. , remove code , paste given below code.

<?xml version="1.0" encoding="utf-8"?> <webview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="fill_parent" />

then create activity illustration given below in src folder

public class exampleactivity extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); webview mywebview = (webview) findviewbyid(r.id.webview); mywebview.loadurl("your url"); } @override protected void onstart() { super.onstart(); // activity become visible. } @override protected void onresume() { super.onresume(); // activity has become visible (it "resumed"). } @override protected void onpause() { super.onpause(); // activity taking focus (this activity "paused"). } @override protected void onstop() { super.onstop(); // activity no longer visible (it "stopped") } @override protected void ondestroy() { super.ondestroy(); // activity destroyed. } }

in android manifest remove activity , add together

<activity android:name=".exampleactivity" android:icon="@drawable/app_icon"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <uses-permission android:name="android.permission.internet" />

then add together uses permission in android manifest file.

android

No comments:

Post a Comment