Android:从我在android中的应用程序调用其他应用程序的活动

时间:2011-07-19 04:11:28

标签: android android-activity

我想从我的应用中调用其他应用活动。所以我使用以下代码

  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.

如何解决这个问题?

1 个答案:

答案 0 :(得分: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>