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 8439673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:03:54+00:00 2026-06-10T08:03:54+00:00

I’m trying to start an activity from an external apk file. The apk file

  • 0

I’m trying to start an activity from an external apk file.
The apk file is a simple text display and I download it from an URL into a local mounted directory in /mnt/sdcard/. Everything works fine to that point.
Now, I want to start an activity from that file and I’m getting errors. Two types, depending on the Intent construction. Here below are the two implementations with the associated LogCat, the ‘targetFilePath’ being the same.
Case I:

try {
    Intent install = new Intent(Intent.ACTION_VIEW)
    .setData(Uri.fromFile(new File(targetFilePath)))
    .setType("application/vnd.android.package-archive");
    startActivity(install);
}
catch (Exception e) {
    e.printStackTrace();
    Toast.makeText(DownloadFile.this, "apk file launch error: " +   e.getMessage(), Toast.LENGTH_LONG).show();
}

The Logcat :

08-26 17:03:02.153: I/ActivityManager(59): Starting activity: Intent { act=android.intent.action.VIEW typ=application/vnd.android.package-archive }
08-26 17:03:02.153: W/System.err(390): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW typ=application/vnd.android.package-archive }
08-26 17:03:02.162: W/System.err(390):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
08-26 17:03:02.162: W/System.err(390):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
08-26 17:03:02.162: W/System.err(390):  at android.app.Activity.startActivityForResult(Activity.java:2817)
08-26 17:03:02.162: W/System.err(390):  at android.app.Activity.startActivity(Activity.java:2923)
08-26 17:03:02.162: W/System.err(390):  at com.agorasoft.sandbox.DownloadFile$1.onClick(DownloadFile.java:137)
08-26 17:03:02.162: W/System.err(390):  at android.view.View.performClick(View.java:2408)
08-26 17:03:02.172: W/System.err(390):  at android.view.View$PerformClick.run(View.java:8816)
08-26 17:03:02.172: W/System.err(390):  at android.os.Handler.handleCallback(Handler.java:587)
08-26 17:03:02.172: W/System.err(390):  at android.os.Handler.dispatchMessage(Handler.java:92)
08-26 17:03:02.172: W/System.err(390):  at android.os.Looper.loop(Looper.java:123)
08-26 17:03:02.182: W/System.err(390):  at android.app.ActivityThread.main(ActivityThread.java:4627)
08-26 17:03:02.182: W/System.err(390):  at java.lang.reflect.Method.invokeNative(Native Method)
08-26 17:03:02.182: W/System.err(390):  at java.lang.reflect.Method.invoke(Method.java:521)
08-26 17:03:02.182: W/System.err(390):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-26 17:03:02.182: W/System.err(390):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-26 17:03:02.182: W/System.err(390):  at dalvik.system.NativeStart.main(Native Method)
08-26 17:03:21.761: D/SntpClient(59): request time failed: java.net.SocketException: Address family not supported by protocol

Case II:

try {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri apkUri = Uri.fromFile(new File(targetFilePath));
    intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
    startActivity(intent);
}
catch (Exception e) {
    e.printStackTrace();
    Toast.makeText(DownloadFile.this, "apk file launch error: " +   e.getMessage(), Toast.LENGTH_LONG).show();
}

Parse error pop-up window: There is a problem parsing the package

The LogCat :

08-26 17:09:48.862: W/PackageParser(329): Unable to read AndroidManifest.xml of /mnt/sdcard/Downloads/ApkTest.apk
08-26 17:09:48.862: W/PackageParser(329): java.io.FileNotFoundException: AndroidManifest.xml
08-26 17:09:48.862: W/PackageParser(329):   at android.content.res.AssetManager.openXmlAssetNative(Native Method)
08-26 17:09:48.862: W/PackageParser(329):   at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:485)
08-26 17:09:48.862: W/PackageParser(329):   at android.content.res.AssetManager.openXmlResourceParser(AssetManager.java:453)
08-26 17:09:48.862: W/PackageParser(329):   at android.content.pm.PackageParser.parsePackage(PackageParser.java:396)
08-26 17:09:48.862: W/PackageParser(329):   at com.android.packageinstaller.PackageUtil.getPackageInfo(PackageUtil.java:79)
08-26 17:09:48.862: W/PackageParser(329):   at com.android.packageinstaller.PackageInstallerActivity.onCreate(PackageInstallerActivity.java:242)
08-26 17:09:48.862: W/PackageParser(329):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-26 17:09:48.862: W/PackageParser(329):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
08-26 17:09:48.862: W/PackageParser(329):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
08-26 17:09:48.862: W/PackageParser(329):   at android.app.ActivityThread.access$2300(ActivityThread.java:125)
08-26 17:09:48.862: W/PackageParser(329):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
08-26 17:09:48.862: W/PackageParser(329):   at android.os.Handler.dispatchMessage(Handler.java:99)
08-26 17:09:48.862: W/PackageParser(329):   at android.os.Looper.loop(Looper.java:123)
08-26 17:09:48.862: W/PackageParser(329):   at android.app.ActivityThread.main(ActivityThread.java:4627)
08-26 17:09:48.862: W/PackageParser(329):   at java.lang.reflect.Method.invokeNative(Native Method)
08-26 17:09:48.862: W/PackageParser(329):   at java.lang.reflect.Method.invoke(Method.java:521)
08-26 17:09:48.862: W/PackageParser(329):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-26 17:09:48.862: W/PackageParser(329):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-26 17:09:48.862: W/PackageParser(329):   at dalvik.system.NativeStart.main(Native Method)
08-26 17:09:48.862: W/PackageInstaller(329): Parse error when parsing manifest. Discontinuing installation
08-26 17:09:49.902: I/ActivityManager(59): Displayed activity com.android.packageinstaller/.PackageInstallerActivity: 1168 ms (total 1168 ms)

Sorry for the lengthy arguments but it seems strange that, first, it doesn’t work, then that I have a different behavior for two syntaxes of the intent/install definition.
Both the calling application and the apk file have the same SDK target/min versions. No special permission set in the calling application manifest for this chunk of code (do I need any?).
Thanks

  • 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-10T08:03:56+00:00Added an answer on June 10, 2026 at 8:03 am

    The docs hold your answer: Intent.setType

    This is used to create intents that only specify a type and not data, for example to indicate the type of data to return.

    This method automatically clears any data that was previously set (for example by setData(Uri)).

    And the docs for Intent.setDataAndType

    This method should very rarely be used — it allows you to override the MIME type that would ordinarily be inferred from the data with your own type given here.

    In short, you don’t need to specify the type when constructing this intent, it will be inferred from the data itself given the URI.

    All of that said, it seems nandeesh’s comment is correct – the package you’re trying to install looks corrupt. It’s also worth noting that if you intend to post this app to the Play Store, apps that download or install other apks are not permitted by the developer agreement.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I have a reasonable size flat file database of text documents mostly saved in

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.