2

Lately I have been working on a new app to which I am trying to add plugins using intents.

I've created a small plugin app called DLC and I'm trying to start an activity inside DLC from my main app called MinePedia when I click a button.

To do so I have created an intent calling the activity in DLC but whenever I click the button i get a Class not found to handle intent error.

Could anyone help me resolve this?

Manifest in DLC

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.dlc"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:logo="@drawable/ic_launcher">
               <action android:name="com.dlc.MainActivity" />

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


    </application>

</manifest>

MainActivity(MinePedia)

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

     Button button2 = (Button) findViewById(R.id.button1);
        button2.setOnClickListener(new OnClickListener() {          
            public void onClick(View v) {
                startActivity(new Intent(getApplicationContext(), MainActivity2.class));

            }
        });




        Button button9 = (Button) findViewById(R.id.info);
        button9.setOnClickListener(new OnClickListener() {          
            public void onClick(View v) {
                startActivity(new Intent(getApplicationContext(), AppInf.class));

            }
        });




        Button button91 = (Button) findViewById(R.id.dlc);
        button91.setOnClickListener(new OnClickListener() {         
            public void onClick(View v) {

                Intent i=new Intent("com.dlc.MainActivity.class"); startActivity(i);
            }
        });






        Button button96 = (Button) findViewById(R.id.help);
        button96.setOnClickListener(new OnClickListener() {         
            public void onClick(View v) {
                startActivity(new Intent(getApplicationContext(), Instruction.class));

            }
        });



        // this
        String ns = Context.NOTIFICATION_SERVICE;
        NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

        int icon = R.drawable.launcher;        
        CharSequence tickerText = "MinecraftPedia"; // ticker-text
        long when = System.currentTimeMillis();         
        Context context = getApplicationContext();     
        CharSequence contentTitle = "MinePedia";  
        CharSequence contentText = "This is the quick launch button for MinePedia";      
        Intent notificationIntent = new Intent(this, MainActivity.class);
        PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
        Notification notification = new Notification(icon, tickerText, when);
        notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

        // and this
        final int HELLO_ID = 1;
        mNotificationManager.notify(HELLO_ID, notification);

}

LOGCAT

08-17 02:39:26.573: E/AndroidRuntime(912): FATAL EXCEPTION: main
08-17 02:39:26.573: E/AndroidRuntime(912): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.dlc.MainActivity.class }
08-17 02:39:26.573: E/AndroidRuntime(912):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622)
08-17 02:39:26.573: E/AndroidRuntime(912):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
08-17 02:39:26.573: E/AndroidRuntime(912):  at android.app.Activity.startActivityForResult(Activity.java:3370)
08-17 02:39:26.573: E/AndroidRuntime(912):  at android.app.Activity.startActivityForResult(Activity.java:3331)
08-17 02:39:26.573: E/AndroidRuntime(912):  at android.app.Activity.startActivity(Activity.java:3566)
08-17 02:39:26.573: E/AndroidRuntime(912):  at android.app.Activity.startActivity(Activity.java:3534)
08-17 02:39:26.573: E/AndroidRuntime(912):  at com.shadycorp.minecraftrecipebook.MainActivity$3.onClick(MainActivity.java:59)
08-17 02:39:26.573: E/AndroidRuntime(912):  at android.view.View.performClick(View.java:4202)
08-17 02:39:26.573: E/AndroidRuntime(912):  at android.view.View$PerformClick.run(View.java:17340)
Shobhit Puri
  • 25,769
  • 11
  • 95
  • 124
Shayden117
  • 252
  • 1
  • 3
  • 17

1 Answers1

1

Clearly, you are trying to open an activity that is in a different package. See the answers on following link on how to actually do this: launch activities from different package

Community
  • 1
  • 1
Shobhit Puri
  • 25,769
  • 11
  • 95
  • 124
  • Happy to help :). If it worked please upvote the answer. All the best! – Shobhit Puri Apr 07 '13 at 10:02
  • ok just one morething.How can i use if and else statement to check if the plugin is installed on the device and if it is launch the plugin but if its not dislpay a toast notifying the user that it isnt installed – Shayden117 Apr 07 '13 at 10:06
  • By plugin do you mean that the activity that you are trying to start( or the application which contains your activity) exists or not? – Shobhit Puri Apr 07 '13 at 10:10
  • If the application exists – Shayden117 Apr 07 '13 at 10:12
  • Buddy, If you google it, you'll get numerous results. Here is one good answer: http://stackoverflow.com/questions/6758841/how-to-know-perticular-package-application-exist-in-the-device – Shobhit Puri Apr 07 '13 at 10:17
  • the intent did work and thanks for your help and i would happily upvote answer but i dont have enough reputation.(I need 15 and only have 13) – Shayden117 Apr 07 '13 at 10:27
  • No problem :). Have fun! – Shobhit Puri Apr 07 '13 at 10:28