Android Open Source - FxExplorer Apk Info Dialog






From Project

Back to project page FxExplorer.

License

The source code is released under:

Apache License

If you think the Android project FxExplorer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package info.breezes.fxmanager.dialog;
//from w  w w .  ja v a 2 s.  com
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.MimeTypeMap;
import android.widget.ImageView;
import android.widget.TextView;

import java.io.File;

import info.breezes.ComputerUnitUtils;
import info.breezes.fxmanager.R;
import info.breezes.fxmanager.countly.CountlyEvent;
import info.breezes.fxmanager.countly.CountlyUtils;
import info.breezes.fxmanager.model.MediaItem;

/**
 * apk detail information dialog
 * Created by Qiao on 2015/1/1.
 */
public class ApkInfoDialog {
    public static void showApkInfoDialog(final Context context, final MediaItem item) {
        PackageManager pm = context.getPackageManager();
        PackageInfo info = pm.getPackageArchiveInfo(item.path, 0);
        if (info == null) {
            return;
        }
        ApplicationInfo appInfo = info.applicationInfo;
        appInfo.sourceDir = item.path;
        appInfo.publicSourceDir = item.path;
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle(item.title);
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        @SuppressLint("InflateParams")
        View view = layoutInflater.inflate(R.layout.dialog_apk_info, null);
        ((ImageView) view.findViewById(R.id.icon)).setImageDrawable(pm.getApplicationIcon(appInfo));
        ((TextView) view.findViewById(R.id.title)).setText(pm.getApplicationLabel(appInfo));
        ((TextView) view.findViewById(R.id.version)).setText(info.versionName);
        ((TextView) view.findViewById(R.id.size)).setText(ComputerUnitUtils.toReadFriendly(item.length));
        ((TextView) view.findViewById(R.id.packageName)).setText(info.packageName);
        try {
            PackageInfo pInfo = pm.getPackageInfo(info.packageName, 0);
            ((TextView) view.findViewById(R.id.installVersion)).setText(String.format(context.getString(R.string.apk_detail_installed), pInfo.versionName));
        } catch (PackageManager.NameNotFoundException e) {
            ((TextView) view.findViewById(R.id.installVersion)).setText(context.getString(R.string.apk_detail_not_install));
        }
        builder.setView(view);
        builder.setPositiveButton(context.getString(R.string.btn_install), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                CountlyUtils.addEvent(CountlyEvent.INSTALL, "");
                Intent intent = new Intent();
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.setAction(android.content.Intent.ACTION_VIEW);
                Uri uri = Uri.fromFile(new File(item.path));
                intent.setDataAndType(uri, MimeTypeMap.getSingleton().getMimeTypeFromExtension("apk"));
                context.startActivity(intent);
            }
        });
        builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        builder.show();
    }
}




Java Source Code List

info.breezes.fx.downloader.ApplicationTest.java
info.breezes.fx.downloader.DlMainActivity.java
info.breezes.fx.editor.ApplicationTest.java
info.breezes.fx.editor.EditorMainActivity.java
info.breezes.fx.player.ApplicationTest.java
info.breezes.fx.player.MainActivity.java
info.breezes.fx.viewer.ApplicationTest.java
info.breezes.fx.viewer.BigImageView.java
info.breezes.fx.viewer.ImageUtility.java
info.breezes.fx.viewer.MainActivity.java
info.breezes.fxmanager.ApplicationTest.java
info.breezes.fxmanager.FxApplication.java
info.breezes.fxmanager.LocalFileSystemProvider.java
info.breezes.fxmanager.MainActivity.java
info.breezes.fxmanager.MediaFragment.java
info.breezes.fxmanager.MediaItemUtil.java
info.breezes.fxmanager.MediaProvider.java
info.breezes.fxmanager.MenuAdapter.java
info.breezes.fxmanager.MimeTypeMap.java
info.breezes.fxmanager.NetUtils.java
info.breezes.fxmanager.PackagesProvider.java
info.breezes.fxmanager.ScanResultActivity.java
info.breezes.fxmanager.ScannerActivity.java
info.breezes.fxmanager.SettingsActivity.java
info.breezes.fxmanager.ShellUtil.java
info.breezes.fxmanager.StorageTool.java
info.breezes.fxmanager.ThemeChooserActivity.java
info.breezes.fxmanager.android.app.QAlertDialog.java
info.breezes.fxmanager.countly.CountlyActivity.java
info.breezes.fxmanager.countly.CountlyEvent.java
info.breezes.fxmanager.countly.CountlyFragment.java
info.breezes.fxmanager.countly.CountlyUtils.java
info.breezes.fxmanager.dialog.ApkInfoDialog.java
info.breezes.fxmanager.dialog.FileInfoDialog.java
info.breezes.fxmanager.dialog.HashInfoDialog.java
info.breezes.fxmanager.model.DrawerMenu.java
info.breezes.fxmanager.model.MediaItem.java
info.breezes.fxmanager.qrcode.QrBitmapDecoder.java
info.breezes.fxmanager.service.FileService.java
net.gescobar.httpserver.Handler.java
net.gescobar.httpserver.HttpConnection.java
net.gescobar.httpserver.HttpServer.java
net.gescobar.httpserver.Request.java
net.gescobar.httpserver.Response.java