2013-01-08 126 views
0

我在包com.qz.launchfoneclayactivity中有一個活動。我需要在包com.qz.Test中啓動一個活動。我試着設置組分與SetClass也沒有幫助,但...下面是我com.qz.launchfoneclayactivity的清單從另一個包中調用活動

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.qz.launchfoneclayactivity" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="16" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 

     <activity android:name="com.x.test.StartUpActivity" />// This is the Activity name in another package 
     <activity 
      android:name="com.qz.launchfoneclayactivity.MainActivity" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 

</manifest> 
下面

是我的第二個包

<?xml version="1.0" encoding="utf-8"?> 
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.qz.test" 
    android:versionCode="xx" 
    android:versionName="x.x.x"> 
    ...................... 


<activity android:name=".StartUpActivity" 
      android:launchMode="singleTop" 
      android:excludeFromRecents="true" 
      android:configChanges="orientation|screenSize|keyboardHidden"     
      android:theme="@android:style/Theme.Translucent.NoTitleBar" >       
      <intent-filter>       
       <action android:name="android.intent.action.VIEW" />       
      </intent-filter>        
      </activity> 
+0

是否想通過該活動啓動您的應用,或者是從其他活動開始該活動? –

+0

除了這些xml文件之外,您還可以在其他活動中顯示您的代碼,您嘗試從其他活動開始此活動。 – Kanth

回答

1

試試清單的一部分因爲從你的應用程序中打開Android應用程序的活動:

Intent intent=new Intent(Intent.ACTION_VIEW); 
intent.setComponent(new ComponentName("com.qz.test", 
          "com.qz.test.StartUpActivity")); 
startActivity(intent); 
+0

我做了這個 Intent oIntent = new Intent(Intent.ACTION_MAIN); (新組件名(「com.qz.test」,「com.qz.test.StartUpActivity」)); 但是當我在startActivity(ointent)之後進行調試時,我沒有在StartUpActivity的oncreate上獲取dubbger。 – user1340801

+0

@ user1340801:因爲您尚未在StartUpActivity活動中添加所以請在StartUpActivity聚合文件中添加此項後嘗試: –

+0

@ user1340801:請參閱我的編輯答案 –

0

如果包屬於不同的應用,標誌着清單文件與android:exported活動。然後外部程序包可以使用帶有完整類名的Intent來啓動它。

Intent start = new Intent(this,<target_class_name>); 
startActivity(start); 
相關問題