1 App Call web
Packagecom.fan.test;ImportJava.util.Timer;ImportJava.util.TimerTask;Importandroid.app.Activity;Importandroid.content.Intent;ImportAndroid.net.Uri;ImportAndroid.os.Bundle; Public classTestactivityextendsActivity {/**Called when the activity is first created.*/@Override//invoke browser to open Baidu when executing app//set a timer to prevent you from jumping Public voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); FinalUri uri = uri.parse ("http://www.baidu.com"); FinalIntent it =NewIntent (Intent.action_view, URI); Timer Timer=NewTimer (); TimerTask Task=NewTimerTask () {@Override Public voidrun () {startactivity (it);//Execution } }; Timer.schedule (Task,1);//after 10 seconds } //automatically exits when returned Public voidOnrestart () {Super. Onrestart (); System.exit (0); }}
Button bn =(Button) Findviewbyid (R.id.button1); Bn.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View v) {//TODO auto-generated Method Stub//Dologin (true,true); //printstringjni ("Hello"); FinalUri uri = uri.parse ("http://www.baidu.com"); FinalIntent it =NewIntent (Intent.action_view, URI); No timer, no need, timer timer.=NewTimer (); TimerTask Task=NewTimerTask () {@Override Public voidrun () {startactivity (it);//Execution } }; Timer.schedule (Task,2000);//after 10 seconds } });
Androidmanifest.xml file included in
<ActivityAndroid:name=". Testactivity "Android:label= "@string/app_name"> <Intent-filter> <ActionAndroid:name= "Android.intent.action.MAIN" /> <categoryAndroid:name= "Android.intent.category.LAUNCHER" /> </Intent-filter> <Intent-filter> <ActionAndroid:name= "Android.intent.action.VIEW" /> <categoryAndroid:name= "Android.intent.category.DEFAULT" /> <categoryAndroid:name= "Android.intent.category.BROWSABLE" /> <DataAndroid:scheme= "http" /> <DataAndroid:scheme= "https" /> <DataAndroid:scheme= "about" /> <DataAndroid:scheme= "JavaScript" /> </Intent-filter> </Activity>
2 Web Call App
Calls between Android apps and the Web