in my app there is a new upgrade
I download my new app version to the sd card and open the apk file by
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(oFile), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
oActivity.startActivity(intent);
code block.
i want to change message on the dialog
the image
You're calling exactly that one Activity with your Intent, that does the work. This particular Activity has the particular layout shown in the image. You can have an Activity that starts with the same Intent and that looks different. Nevertheless, the new Activity wouldn't do the work necessary to install the apk-file.
It's all about taking care, that no App can bypass the rights handling and needs to get rights granted by the user and nobody else (especially no App)
In short: No, not possible.
Related
I'm trying to have other apps share PDF files with mine, I have an intent filter for android.intent.action.SEND type pdf files but some apps send the intent with the FLAG_ACTIVITY_CLEAR_TASK which closes the activity that was already running.
Is there any way to ignore this flag? I want to keep the current activity running when shared to my app.
EDIT: a good example
I share a PDF with google drive pdf viewer, my activity that is already running picks it up and the intent is received in "onNewIntent" (desired).
When I do the same thing with Samsungs "my files" my activity gets restarted and the intent is given to "onCreate" (not desired)
I share a PDF with google drive pdf viewer, my activity that is already running picks it up and the intent is received in "onNewIntent" (desired).
When I do the same thing with Samsungs "my files" my activity gets restarted and the intent is given to "onCreate" (not desired)
Your app should work correctly regardless of how it's invoked. What difference does it make to you whether it's a new instance receiving the intent or the existing one? You're not always going to have an existing instance around, right? If you share from Google before starting your activity, you'll be in the same position, won't you?
in App A, i have UI Box. Is it possible to load App B (APK) then load and run it into the UI Box ?
so, its like run App B with frame from App A.
I would say it is not possible to install another application from one application as android made a sandbox for each application and prevent it from touching to other applications.
NOTE: you can invoke an android package installer via Intent.
File apkFullPath = getFileStreamPath("name_of_downloaded_app.apk");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(apkFullPath), "application/vnd.android.package-archive");
startActivity(intent);
Hope this will help and solve your problem.
You cannot run an apk without instsalling it first. What you can do is start intent for installing it and then use it as you wish.
Read this ans to start intent for installing an apk:
Install apk programmatically
In fact, I want to be noticed when the program is downloaded without the user having to install their own apps (Install without show permissions activity).
Now I use the following code, and I want to change this code to answer my question.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file),"application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
The following image is displayed after downloading the app from my server and i dont want to show
I want to give the user the choice of opening an audio stream url with an audio player that he already have installed.
The following code works as so far that the user getting a list of installed audio apps and can choose between then.
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(stream.getAudio()), "audio/*");
startActivity(intent);
But it will open an intent that lives inside my app only. Therefor the playback will stop if the user closes my app. How can I change the behaviour so that not an new activity is started but the whole app is launched and is detached from my app.
I guess it's because the audio player is opened in the same task stack of your app.
Try Intent.FLAG_ACTIVITY_NEW_TASK to start it as a new task, like:
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
See Tasks and Back Stack to learn more.
is it possible to call more packages in single project,without installing the other packages in emulator/phone,want single apk file..I Kept this code...but is possible when the package is available in emulator/phone..Please suggest me...if that package is not available in emulator/phone
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName(
"com.abc.def.packname",
"com.abc.def.packname.MyActivity"));
startActivity(intent);
To be able to use an Intent to launch any Activity, there must be an Activity available to Handle it. This applies for both direct intents that target one particular Activity, and more general intents which would result in a Chooser dialog, like the share intent.
So in short, yes, the package you are referencing must be installed as well, or else your app will crash. If you have access to the source code of the other project, you could combine them into one. If this isn't possible, you could request that the user installs the other app when your app starts.