How to install application directly to device from web - android

I have one server, and on that server I have uploaded one apk file. There is a button on my webpage that, when clicked, the application should be directly installed to device instead of being downloaded to local storage.
I need same functionality like we install apps from google play store.
If any one knows this, then it will be appreciated.
I have not found any solutions of this through google.
Thanks.

This is not possible. Fortunately. Imagine the security breach this would be. Any Website could force install apps. This would open the doors for any kind of Virus.

You cannot do that as our friends advised you. I have tried by these ways for installing APK from my own server
You can download the APK from the server and save it in some folder
Add permission in manifest
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Use this demo code for downloading and installing the APK
Downloading APK from server
String PATH = Environment.getExternalStorageDirectory()+ "/yourpath/";
File file = new File(PATH);
if (!file.exists()) {
file.mkdirs();
}
File outputFile = new File(file,
"your.apk");
if (outputFile.exists()) {
outputFile.delete();
}
FileOutputStream fileOuputStream = new FileOutputStream(
outputFile);
fileOuputStream.write(bResponse);
fileOuputStream.close();
Installation of APK after Download completes
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(Environment
.getExternalStorageDirectory()+ "/your path/"+ "yourapkname.apk")),
"application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
3.After Installation you can delete the APK from folder location

Any third party cannot install the application of their own on the Android Device directly. Otherwise they need some root permission that should be declared in device Kernel. Google Play can directly install by sending commands to Play Store to install the particular app as Google is in fact the owner of Android and indirectly Device Administrator which have full access to your device kernel.

Related

How to install APK stored in internal memory without SD Card

I've been trying to find out how to install stored APK from internal memory, but I continually get errors.
I've tried getFilesDir() but it returns
08-14 03:18:09.127 10089-10089/? W/zipro: Error opening archive /data/user/0/package_name/files/app-release.apk: I/O Error
08-14 03:18:09.127 10089-10089/? D/asset: failed to open Zip archive '/data/user/0/package_name/files/app-release.apk'
08-14 03:18:09.127 10089-10089/? W/PackageInstaller: Parse error when parsing manifest. Discontinuing installation
I've also tried Environment.getDownloadCacheDirectory() but I get a similar result.
I am attempting to install on a non-rooted device, but I have signature level app permission.
How do I install app on a non-rooted device?
Even
public void installAPKManual(String filename) {
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(new File(filename));
intent.setDataAndType(uri, "application/vnd.android.package-archive");
startActivity(intent);
}
doesn't work. Parse error.
Update
It works after I use
file.setReadable(true, false)
to get world readable permission, but I wonder if there is a better way?
If you are trying to retrieve the file from Environment then you need storage permission.
or if you are trying to get the file from your private storage getCacheDir() or getFileDir() you don't need permission but you must use File Provider.
if these are not the case try to install the APK manually first and see that everything is ok with the APK or not!!!

How to run install app in internal files dir?

I have some lines of code and apk file in internal cache dir:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(newFile(context.getCacheDir() + "/update.apk")), "application/vnd.android.package-archive");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
But I had a parsing error: "There was a problem parsing the package"
Thank You for helping!
Third-party apps, including the package installer, have no access rights to that file.
On Android N, they have finally fixed the problem with installing apps via a ContentProvider, like FileProvider. For versions prior to that, you can install from external storage, or maybe use MODE_WORLD_READABLE (deprecated, and banned on Android N) to allow that file to be read from internal storage.

Android - How I can use OpenCV without install OpenCV Manager Application

Is there any way to run my app with OpenCV without install an extra application (OpenCV Manager)?
I can't ask my users to install an extra app to run my application.
Thanks.
Copy all the library's files.
Or simply install the manager within the app like:
Intent promptInstall = new Intent(Intent.ACTION_VIEW)
.setDataAndType(Uri.parse("file:///path/to/org.opencv.engine.v2.14.apk"),
"application/vnd.android.package-archive");
startActivity(promptInstall);
add this permission:
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />

How to create folder in Computer\Nexus 5\Internal storage folder

First of all, I'm an android newbie. Now my question...
I want to create a folder with some files, so I can easily access them when I plug in my droid via USB.
"directory.exists" returns true, saying the folder exists, but when I go to Windows File Explorer, Computer\Nexus 5\Internal storage, I do not see my app folder listed in there.
getExternalStorageDirectory returns: /storage/emulated/0/MyAppName
File directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/MyAppName/");
if (!directory.exists()) {
directory.mkdir();
}
I have added
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
in manifest.
What am I doing wrong?
You're not doing anything wrong. Android does.
That MTP connection is unreliable as contents displayed is not in sync with the latest files wrote on the phone.
You can cause a manual rescan or reboot the phone... see below:
android bug
similar question with workarounds

Programmatically install Android Applications

I have the following problem:
As described at Android: install .apk programmatically, I install an APK file successfully on an Android device. Unfortunately I have the problem that when I try to install a second APK file, get the message: Package not installed.
In the debugger I see:
Asset path / sdcard / myAPK.apk
neither directory nor file
This may help you:
protected void installApkfile(String apkFileName) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(
new File(Environment.getExternalStorageDirectory() + "/download/"
+ apkFileName)), "application/vnd.android.package-archive");
startActivityForResult(intent,0);
}
Here my .apk file is in sd card download folder.
If by "asset path" you really mean that the APK is packaged as an asset, that will not work. The APK must be an actual file on the filesystem, and an asset remains packaged inside of its hosting APK. See: Can We Install an APK From a ContentProvider?

Categories

Resources