Android在瀏覽器啟動APP,android瀏覽器app

來源:互聯網
上載者:User

Android在瀏覽器啟動APP,android瀏覽器app


要想在瀏覽器啟動APP的方法如下:


在需要跳轉的ACTIVITY中添加intent-filter的相關資訊:


<intent-filter>
    <data android:scheme="com.example.scheme" />
</intent-filter>


執行個體如下:
<activity android:name=".BrowActivity" >
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
   <data android:scheme="com.example.scheme" />
   <action android:name="android.intent.action.VIEW" />
</intent-filter>
     </activity>
 
 
 
然後再HTML添加如下連結即可:<a href="my.special.scheme://other/parameters/here">


進入APP之後,可以使用getIntent()來擷取URL攜帶的相關資訊:


EG:http://twitter.com/status/1234
Uri data = getIntent().getData();
String scheme = data.getScheme(); // "http"
String host = data.getHost(); // "twitter.com"
List<String> params = data.getPathSegments();
String first = params.get(0); // "status"
String second = params.get(1); // "1234"
android怎實現開機自動啟動Service或app

Android手機在啟動的過程中會觸發一個Standard Broadcast Action,名字叫android.intent.action.BOOT_COMPLETED(記得只會觸發一次呀),在這裡我們可以通過構建一個廣播接收者來接收這個這個action.下面我就來簡單寫以下實現的步驟:2. 第一步:首先建立一個廣播接收者,重構其抽象方法 onReceive(Context context, Intent intent),在其中啟動你想要啟動的Service或app。 import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; public class BootBroadcastReceiver extends BroadcastReceiver { //重寫onReceive方法 @Override public void onReceive(Context context, Intent intent) { //後邊的XXX.class就是要啟動的服務 Intent service = new Intent(context,XXXclass); context.startService(service); Log.v("TAG", "開機自動服務自動啟動....."); //啟動應用,參數為需要自動啟動的應用的包名 Intent intent = getPackageManager().getLaunchIntentForPackage(packageName); context.startActivity(intent ); } } 第二步:配置xml檔案,在receiver接收這種添加intent-filter配置 <receiver android:name="BootBroadcastReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"></action> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </receiver> 第三步:添加許可權 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> 啟動APP: 因為做一個hotkey的項目,其中有幾個快速鍵需要啟動系統內建的browser和email。因為剛剛開始學習android,在網上找到啟動browser和email的方法都是利用ACTION_VIEW和SENDTO這樣的intent去啟動browser和email.問題來了:1.如果是這樣的話,啟動browser需要自己預設一個網址,然後呼叫瀏覽器開啟改網址。2.啟動email,也是需要自己設定一個賬戶地址......餘下全文>>
 
Android手機上做一個APP,以瀏覽器的形式開啟我們公司之間的網址,問下面的導航條是用什控制項?

可以用View寫一個,然後在上面添加一個個的按鈕!
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.