2011-07-19 36 views
2

我想從我的應用程序調用其他應用程序活動。所以我用下面的代碼Android:從我的應用程序中調用其他應用程序的活動android

Intent i = new Intent(); 
    i.setComponent(new ComponentName("com.android.DailyDeals", 
          "com.android.DailyDeals.TodaysDeals_AM")); 
    startActivity(i); 

但我得到以下異常:

Caused by: java.lang.SecurityException: Permission Denied: 
     starting Intent { cmp=com.android.DailyDeals/.TodaysDeals_AM } from 
     ProcessRecord{44f9b8b0 399:com.prabhu.android/10041} (pid=399, uid=10041) 
     requires null. 

如何解決這個問題?

回答

2

我認爲這將幫助你 在你的java文件中做這樣的代碼。

startActivity(new Intent("com.name of your class"));you have to write your package name .classname inside it. 
& also declare this activity into your **mainfest** file 

    <activity android:name=".name of your class" 
         android:label="@string/app_name"> 
       <intent-filter> 
        <action android:name="com.diffrentview.MYFILE" /> 
        <category android:name="android.intent.category.DEFAULT" /> 
       </intent-filter> 
      </activity> 
相關問題