Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8047979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:17:03+00:00 2026-06-05T06:17:03+00:00

I have two Android applications,suppose they are A and B, A has five activities

  • 0

I have two Android applications,suppose they are “A” and “B”, “A” has five activities and I want to call its specific activity from button click event of “B”.
I tested this way of calling one application from another:

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.testapp.ws");
startActivity(LaunchIntent);

“com.testapp.ws” is the package name of “A”.

This runs “A” from its first activity again not from the specific activity.
How can I call A’s specified activity?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:17:04+00:00Added an answer on June 5, 2026 at 6:17 am

    Grant,

    The issue here is clearly a misunderstanding of the Android Application Model. Commonsware is absolutely correct about how to solve this problem. However, without understanding Android fundamentals, I can see why you are having difficulty applying it. So, a quick explanation:

    Every action in Android begins with an Intent. This is particularly true for Activities. Every Activity has an Intent. To make the interface easy for the developers, you may respond to an Intent from the OS, OR you may create an Intent from the Activities class to use. In general, it is best practice to do the first option.

    Responding to an Intent

    When picking an Intent to respond to, you may literally respond to any Intent. This is called an Action. If I created an Intent called “FOO”, the Bar Activity could pick it up and respond. We have conventions, however, and the primary of those is to prepend your package name to any Intent you make. For example “com.company.package.FOO”. Simply put, this is so that we avoid collisions with other apps.

    Every Activity may respond to different events. This is defined in the AndroidManifest.xml.

    <activity android:name="Activity3" ... >
        <intent-filter>
          <action android:name="com.company.package.FOO"/>
          <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    

    Above, we also set the category to DEFAULT, so that unless the user changes it, we’ll be the only app that responds to our custom Intent. The way that we then call the Intent is by using the SAME NAME that we created (i.e. “com.company.package.FOO”)

    startActivity(new Intent("com.company.package.FOO"));
    

    That’s how it works! You would simply change the above “com.company.package.FOO” to your package name (defined by your application) and something meaningful. An example is “com.testapp.ws.SWAT_FLIES”.

    Why your code doesn’t work

    Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.testapp.ws");
    

    The above code looks for a specific KIND of Intent action. Remember when you made the AndroidManifest and the first Activity you put:

     <action android:name="android.intent.action.MAIN">
     <category android:name="android.intent.category.LAUNCHER">
    

    Well… getLaunchIntentForPackage() only gets the Intent for that first Activity. That’s WHY we make a custom Intent… First, because we don’t really want it to be our 3rd Activity to be our start up… And second, becuase the OS will tell us only the startup Activity. We have to tell it with our OWN action (i.e. “com.testapp.ws.SWAT_FLIES”)

    Hope this helps,

    FuzzicalLogic

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android application that contains two Activities . Activity A has a
I have two applications, one for android and one for blackberry and I want
I have two android applications. The apks are Hello.apk and Fonts.apk I would like
I have two android applications that I have developed. I need to compare the
I have developed two separate applications 1) android 2.1 that takes user input /
I am relatively new to android. I have two applications A and B. I
i have two applications which i want them to share the same arraylist. how
Let say that I have two Activity to develop in Android. Upon the end
I have two Android projects in Eclipse. I copied the one project from the
There are two Android applications calling each other: App1, App2. steps: start App1 from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.