0

I got log cat message from startAnotherActivity() method

private void startAnotherActivity() {
    Log.i(TAG, "Entered startAnotherActivity()");

    Intent intent = new Intent();
    intent.setAction(ANOTHER_ACTIVITY);
    intent.addCategory("android.intent.category.DEFAULT");
    startActivity(intent);
}

Another activity doesn't start, no other messages in log cat.

How can I resolve this issue?

UPDATE#1:

Sorry, I forgot to mention that AnotherActivity is an Activity in the other application, and therefore ANOTHER_ACTIVITY == 'some.other.app.domain.ANOTHER_ACTIVITY'

Shouldn't Dalvik complain if it cannot find specified activity?

zuba
  • 1,378
  • 1
  • 14
  • 42

3 Answers3

0

One possible reason may be not declaring other activity in the manifest. You can do this like the following:

    <activity android:name="your.package.your.activity">
    </activity>

And then you can start the activity by doing the following:

Intent intent = new Intent(CurrentActivity.this, NewActivity.class);
startActivity(intent);

Hope this helps.

yrazlik
  • 9,023
  • 26
  • 84
  • 145
  • Thank you for that, but it can't help 'cause I need to launch an activity from another app – zuba Oct 23 '14 at 14:46
  • @zuba maybe this link may help then. http://stackoverflow.com/questions/3872063/launch-an-application-from-another-application-on-android – yrazlik Oct 24 '14 at 05:55
0

Since it's an activity in another application, you may need to set the component (fully qualified package name and fully qualified activity name). See here: How to start activity in another application?

Or here: Launch an application from another application on Android

Community
  • 1
  • 1
kha
  • 16,333
  • 9
  • 28
  • 57
  • Looking promising, Thank you! I'll try that right now – zuba Oct 23 '14 at 14:33
  • Just have tried, but it ended up with the same result – zuba Oct 23 '14 at 14:45
  • Did you try both approaches? (there were 2 links). Did you get an error this time or simply nothing, like before? – kha Oct 23 '14 at 15:17
  • I missed the second, but yes, just now I tried it. Right the same result. – zuba Oct 23 '14 at 16:26
  • Despite I found in docs `Caution: If you invoke an intent and there is no app available on the device that can handle the intent, your app will crash.` I get my log cat message and my app neither crash, nor shows ohter's app activity. – zuba Oct 23 '14 at 16:27
0

Finally I found out my mistake.

In the project there are two similar messages in two activities, so I thought that runs one, but that was another.

Thank you for your assistance!

zuba
  • 1,378
  • 1
  • 14
  • 42