2011-09-10 111 views
0

我想添加按鈕到我們的移動web應用程序,它允許用戶啓動我們的android應用程序。從android瀏覽器啓動(並安裝)android應用程序

因爲我不知道,如果應用程序已經在設備上安裝,我需要:

  • 如果應用程序沒有安裝在第一
  • 啓動應用程序安裝應用程序

回答

1

不能強制安裝在用戶身上。

你可以得到的最接近的是要在你的應用的活動有一個<intent-filter>映射到一個網址,您的網站:

<activity android:name="URLHandler" 
       android:label="@string/app_name"> 
     <intent-filter android:label="@string/app_name"> 
      <action android:name="android.intent.action.VIEW" /> 
      <data android:scheme="http" 
       android:host="commonsware.com" 
       android:path="/whatever" 
      /> 
      <category android:name="android.intent.category.BROWSABLE" /> 
     </intent-filter> 
    </activity> 

然後,在你的Web應用程序,有一個鏈接到該網址。當用戶點擊鏈接時,在安裝了您的應用的設備上,您指定的活動將打開。在沒有安裝應用程序的設備上,用戶將被帶到您指定的網頁,在那裏您可以提示他們如何下載和安裝您的應用程序。

-2

如果(v.getId()== R.id.ImageButton01){

 if (keyCode == KeyEvent.KEYCODE_ENTER) { 


      Toast.makeText(this, "Application Name", Toast.LENGTH_LONG).show(); 
      Intent i = new Intent(); 

      i.setAction(Intent.ACTION_VIEW); 

      i.setClassName("com.xxx.your_package_name", 
        "com.xxx.your_class_name"); 

      startActivity(i); 

     } 
    } 

嘗試{

startActivity(intent); 

}

趕上(ActivityNotFoundException E){ 吐司。 makeText(OpenPdf.this,

"No Application Available to View PDF", 

    Toast.LENGTH_SHORT).show(); 

//連接到指定的路徑爲downloadinng //使用activitynot發現異常趕上如果沒有安裝,給用戶的//你下載的文件的一些事情升 }

+0

我瞭解移動Web應用程序,網頁不是路徑Java應用程序。 –

+0

@ maciek你想要搜索天氣,apllication已經安裝或沒有引用你的應用程序包和活動名稱,你無法發現它的天氣它是否存在或不存在。要麼你正在使web應用程序或android應用程序ultimatley你的應用程序是在android你想讓它安裝在Android設備上。 – aditya

相關問題