Calls between Android apps and the Web

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.