1

我遇到了從我的其他活動開始的問題。我知道這必須在其他地方完成,因爲有那麼多的啓動程序應用程序在那裏使用包管理器開始特定活動...如何在具有活動名稱字符串但不包含Activity.Class時啓動另一個活動?

我可以得到一個敏感性名稱我想從包管理器開始,但我怎麼能解析這個並把它變成一個意圖?因爲我不能進入這個班級......另外我想開始具體的活動並且不從包裝中啓動主要目的...

我確定有人必須在這個地方做這個..這在活動中有點重要,不是嗎?

回答

3

假設你已經在你的AndroidManifest.xml

<!-- The askUser dialog activity --> 
    <activity android:theme="@android:style/Theme.Dialog" 
       android:name="my.app.AskUserActivity" 
       android:excludeFromRecents="true" 
       android:screenOrientation="portrait"> 
     <intent-filter> 
      <action android:name="my.app.intents.AskUserConfirmConnect"/> 
      <category android:name="android.intent.category.DEFAULT" />     
     </intent-filter> 
    </activity>  

以下然後你就可以通過名字來稱呼這個活動,像這樣:

Intent dlgIntent = null; 

dlgIntent = new Intent("my.app.intents.AskUserConfirmConnect"); 
dlgIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
dlgIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); 
context.startActivity(dlgIntent); 
相關問題