How to Run (Not Only Install) an Android Application Using .Apk File

How do you install an APK file in the Android emulator?

You can simply drag and drop the .apk file of your application to the emulator and it will automatically start installing.

Another option:


Windows:

  1. Execute the emulator (SDK Manager.exe->Tools->Manage AVDs...->New then Start)
  2. Start the console (Windows XP), Run -> type cmd, and move to the platform-tools folder of SDK directory.
  3. Paste the APK file in the 'android-sdk\tools' or 'platform-tools' folder.
  4. Then type the following command.

adb install [.apk path]

Example:

adb install C:\Users\Name\MyProject\build\Jorgesys.apk

Linux:

  1. Copy the apk file to platform-tools in the android-sdk linux folder.
  2. Open Terminal and navigate to platform-tools folder in android-sdk.
  3. Then Execute this command -

./adb install FileName.apk


  1. If the operation is successful (the result is displayed on the screen), then you will find your file in the launcher of your emulator.

Mac:

PATH=$PATH:~/Library/Android/sdk/platform-tools

Example : PATH=$PATH:/users/jorgesys/eclipse/android-sdk-mac_64/tools

Then run adb.

Mac:

1.Run the emulator,

2.then copy your .apk file and paste into /Users/your_system_username/Library/Android/sdk/platform-tools,

if you are not able to find sdk path in your mac system, do the following steps: Open finder->select Go option on top menu -> select Go to Folder option -> it will popup a window with a textfield: /Users/your_system_username/Library/Android/sdk/ -> now open platform-tools folder and paste your copied .apk file,


  1. Now open the terminal and type the following:
    cd Library/Android/sdk/platform-tools

  2. execute the following in your terminal: ./adb install yourapkfilename.apk if you get the following error message: error: no devices found - waiting for device, follow step 5.

  3. Run your emulator from Android Studio, once emulator active then repeat step 4, you will see the success message on your terminal.

How to install an Android application on a real device without publishing and Eclipse?

You can deploy the .apk file on your local server(apache or jboss) with a static IP to make the file available for download. Now just open the download link of the apk file in your mobile browser. The device will automatically start the installation after the download completes.

Can we restrict to install .apk files in our device?

save all the device ID into an xml file and bundle it with your application when application starts just get Device id and compare it with the list you have ,if the id match then start the application or show error

you cannot block other users to block installation but I think they wont be able to use the app or even open the application if you follow above procedure

How do I avoid multiple apk install promps on an Android programmatic install?

I managed to get it working properly without the duplicates by having our background service call a custom activity:

public static void installDownloadedApplication(Context context) {
Intent intent = new Intent(context, InstallActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}

Then our custom activity does what the background service used to do:

/**
* We use an activity to kick off the installer activity in order to avoid issues that arise when kicking off the apk installer from a background services
* for multiple applications at the same time.
* */
public class InstallActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
File sdcard = Environment.getExternalStorageDirectory();
File file = new File(sdcard, Constants.APPLICATION_CODE+".apk");
Uri uri = Uri.fromFile(file);
intent.setDataAndType(uri, "application/vnd.android.package-archive");
this.startActivity(intent);
}

@Override
protected void onResume() {
super.onResume();
finish();
}

}

Install an apk file from command prompt?

You can use the code below to install application from command line

adb install example.apk

this apk is installed in the internal memory of current opened emulator.

adb install -s example.apk

this apk is installed in the sd-card of current opened emulator.

You can also install an apk to specific device in connected device list to the adb.

adb -s emulator-5554 install myapp.apk

Refer also to adb help for other options.

Can i prevent an application from being installed in a particluar device in android?

AFAIK, Its not possible to prevent App installation, if one has the APK file. Though you could prevent the app to run on particular device as I think you have done.

Else, you can have a look here, if you want to install the app over the network. Using this, you can install the app only on the devices you want to allow.

Install Application programmatically on Android

You can easily launch a market link or an install prompt:

Intent promptInstall = new Intent(Intent.ACTION_VIEW)
.setDataAndType(Uri.parse("file:///path/to/your.apk"),
"application/vnd.android.package-archive");
startActivity(promptInstall);

source

Intent goToMarket = new Intent(Intent.ACTION_VIEW)
.setData(Uri.parse("market://details?id=com.package.name"));
startActivity(goToMarket);

source

However, you cannot install .apks without user's explicit permission; not unless the device and your program is rooted.



Related Topics



Leave a reply



Submit