简体   繁体   中英

Android accessing activities from different package/application(folder in package explorer)

I have two packages(or application .I don't know what is it called as).I have a activity A in feed and another activity B in the sms.A activity should call activity BI tried the answers present on the previous queries.It didn't work.Can anybody help please.

My package explorer looks like this

  -feed -src -example.me.feed -A.java -res -activity_a.xml - Manifeft -SMS -src -info.me.sms -B.java -res -b.xml -Manifeft 

You can use this code(first set packageName and context ):

PackageManager manager = context.getPackageManager();
    try {
        Intent i = manager.getLaunchIntentForPackage(packageName);
        if (i == null) {
            return false;
            //throw new PackageManager.NameNotFoundException();
        }
        i.addCategory(Intent.CATEGORY_LAUNCHER);
        context.startActivity(i);
        return true;
    } catch (PackageManager.NameNotFoundException e) {
        return false;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM