Android APK Installation Check installApk(Context context, File file)

Here you can find the source of installApk(Context context, File file)

Description

install Apk

License

Apache License

Declaration

public static void installApk(Context context, File file) 

Method Source Code

//package com.java2s;
/*/*from ww w. ja  va2  s.c  om*/
 * Copyright (C) 2012 www.amsoft.cn
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.content.Context;
import android.content.Intent;

import android.net.Uri;

import java.io.File;

public class Main {

    public static void installApk(Context context, File file) {
        Intent intent = new Intent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setAction(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(file),
                "application/vnd.android.package-archive");
        context.startActivity(intent);
    }
}

Related

  1. isAppInstalled(Context ctx, String uri)
  2. isApkInstalled(Context context, String packageName)
  3. installApk(Context context, File file)
  4. uninstallApk(Context context, String packageName)
  5. verifySampleSetup(Activity activity, int... resIds)
  6. installWatchapp(final Activity parent, final String pbwFilename, final String appstoreUid)