當前位置: 首頁>>代碼示例>>Java>>正文


Java PackageManager.getLaunchIntentForPackage方法代碼示例

本文整理匯總了Java中android.content.pm.PackageManager.getLaunchIntentForPackage方法的典型用法代碼示例。如果您正苦於以下問題:Java PackageManager.getLaunchIntentForPackage方法的具體用法?Java PackageManager.getLaunchIntentForPackage怎麽用?Java PackageManager.getLaunchIntentForPackage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.pm.PackageManager的用法示例。


在下文中一共展示了PackageManager.getLaunchIntentForPackage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: NextLauncher

import android.content.pm.PackageManager; //導入方法依賴的package包/類
private void NextLauncher() {
    try {
        PackageManager manager = getActivity().getPackageManager();
        Intent intent = manager.getLaunchIntentForPackage("com.gtp.nextlauncher");

        if (intent == null) {
            intent = manager.getLaunchIntentForPackage("com.gtp.nextlauncher.trial");
        }

        Intent next = new Intent("com.gau.go.launcherex.MyThemes.mythemeaction");
        next.putExtra("type", 1);
        next.putExtra("pkgname", BuildConfig.APPLICATION_ID);
        getActivity().sendBroadcast(next);
        startActivity(intent);

    } catch (Exception e) {
        Toast.makeText(getActivity(), R.string.launcher_not_found, Toast.LENGTH_SHORT).show();
    }
}
 
開發者ID:iAcn,項目名稱:MBEStyle,代碼行數:20,代碼來源:ApplyFragment.java

示例2: NavigateToOtherApplication

import android.content.pm.PackageManager; //導入方法依賴的package包/類
public boolean NavigateToOtherApplication(
        @NonNull String packageName,
        boolean finish) {
    PackageManager packageManager = _context.getPackageManager();
    try {
        Intent startAppIntent = packageManager.getLaunchIntentForPackage(packageName);

        if (startAppIntent == null) {
            return false;
        }

        startAppIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        _context.startActivity(startAppIntent);

        if (finish) {
            ((Activity) _context).finish();
        }

        return true;
    } catch (Exception e) {
        _logger.Error(e.toString());
        return false;
    }
}
 
開發者ID:GuepardoApps,項目名稱:PasswordSafe-AndroidClient,代碼行數:25,代碼來源:NavigationController.java

示例3: getContentIntent

import android.content.pm.PackageManager; //導入方法依賴的package包/類
private PendingIntent getContentIntent(AppUpdateStatus entry) {
    switch (entry.status) {
        case UpdateAvailable:
        case ReadyToInstall:
            // Make sure we have an intent to install the app. If not set, we create an intent
            // to open up the app details page for the app. From there, the user can hit "install"
            return getAppDetailsIntent(entry.apk);

        case InstallError:
            return getAppErrorIntent(entry);

        case Installed:
            PackageManager pm = context.getPackageManager();
            Intent intentObject = pm.getLaunchIntentForPackage(entry.app.packageName);
            if (intentObject != null) {
                return PendingIntent.getActivity(context, 0, intentObject, 0);
            } else {
                // Could not get launch intent, maybe not launchable, e.g. a keyboard
                return getAppDetailsIntent(entry.apk);
            }
    }
    return null;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:24,代碼來源:AppUpdateStatusManager.java

示例4: startThirdApp2

import android.content.pm.PackageManager; //導入方法依賴的package包/類
/**
 * 啟動製定包名的其他應用
 * http://www.jianshu.com/p/42ae7066f8f3
 *
 * @param packageNameStr packageName
 */
public static boolean startThirdApp2(Activity activity, String packageNameStr) {
    boolean isSuccess;
    if (activity == null || activity.isFinishing()) return false;
    try {
        PackageManager packageManager = activity.getApplicationContext().getPackageManager();
        if (checkPackInfo(packageManager, packageNameStr)) {
            Intent intent = packageManager.getLaunchIntentForPackage(packageNameStr);
            activity.startActivity(intent);
            Toast.makeText(activity, "啟動" + packageNameStr, Toast.LENGTH_SHORT).show();
            isSuccess = true;
        } else {
            isSuccess = false;
            Toast.makeText(activity, "沒有安裝" + packageNameStr, Toast.LENGTH_SHORT).show();
        }


    } catch (Throwable throwable) {
        throwable.printStackTrace();
        isSuccess = false;
    }
    return isSuccess;
}
 
開發者ID:androidmalin,項目名稱:StartThirdApp,代碼行數:29,代碼來源:ActivityStartUtil.java

示例5: getNameOfAppsArray

import android.content.pm.PackageManager; //導入方法依賴的package包/類
public ArrayList<String> getNameOfAppsArray() {
    PackageManager pm = context.getPackageManager();
    listOfAppInfo = pm.getInstalledApplications(pm.GET_META_DATA);
    for(ApplicationInfo app : listOfAppInfo) {

        if(pm.getLaunchIntentForPackage(app.packageName) != null) {
            // apps with launcher intent
            if((app.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 1) {
                // updated system apps

            } else if ((app.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
                // system apps

            } else {
                // user installed apps
                nameOfAppsArray.add((String) pm.getApplicationLabel(app));
            }
        }
    }
    return nameOfAppsArray;
}
 
開發者ID:01sadra,項目名稱:Detoxiom,代碼行數:22,代碼來源:AppNameAndLogoProvider.java

示例6: getAppLogosArray

import android.content.pm.PackageManager; //導入方法依賴的package包/類
public ArrayList<Drawable> getAppLogosArray() {
    PackageManager pm = context.getPackageManager();
    listOfAppInfo = pm.getInstalledApplications(pm.GET_META_DATA);

    for(ApplicationInfo app : listOfAppInfo) {

        if(pm.getLaunchIntentForPackage(app.packageName) != null) {
            // apps with launcher intent
            if((app.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 1) {
                // updated system apps

            } else if ((app.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
                // system apps

            } else {
                // user installed apps
                appLogosArray.add(app.loadIcon(pm));

            }
        }

    }
    return appLogosArray;
}
 
開發者ID:01sadra,項目名稱:Detoxiom,代碼行數:25,代碼來源:AppNameAndLogoProvider.java

示例7: doInBackground

import android.content.pm.PackageManager; //導入方法依賴的package包/類
@Override
protected AppsItemViewHolder doInBackground(Object... params) {
    PackageManager packageManager = (PackageManager) params[0];
    AppsItemViewHolder holder = (AppsItemViewHolder) params[1];
    try {
        Intent launchIntent = packageManager.getLaunchIntentForPackage(holder.packageName);
        if (launchIntent == null) {
            holder.icon = packageManager.getApplicationIcon(holder.packageName);
        } else {
            holder.icon = packageManager.resolveActivity(launchIntent, 0).activityInfo
                    .loadIcon(packageManager);
        }
    } catch (PackageManager.NameNotFoundException e) { // NOSONAR
        // do nothing
    }
    return holder;
}
 
開發者ID:brevent,項目名稱:Brevent,代碼行數:18,代碼來源:AppsIconTask.java

示例8: canPreventSystemPackage

import android.content.pm.PackageManager; //導入方法依賴的package包/類
private static boolean canPreventSystemPackage(PackageManager pm, ApplicationInfo appInfo) {
    // cannot prevent launcher
    if (isLauncher(pm, appInfo.packageName)) {
        return false;
    }
    // can prevent system packages with launcher
    if (pm.getLaunchIntentForPackage(appInfo.packageName) != null) {
        return true;
    }
    if (isSystemSignaturePackage(pm, BuildConfig.APPLICATION_ID)) {
        // shouldn't happen, but for some abnormal rom
        return GmsUtils.isGapps(appInfo.packageName);
    } else {
        return !isSystemSignaturePackage(pm, appInfo.packageName);
    }
}
 
開發者ID:brevent,項目名稱:prevent,代碼行數:17,代碼來源:PackageUtils.java

示例9: onCreateContextMenu

import android.content.pm.PackageManager; //導入方法依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    BreventActivity activity = (BreventActivity) mFragment.getActivity();
    menu.setHeaderTitle(label);
    menu.add(Menu.NONE, R.string.context_menu_select, Menu.NONE,
            activity.getString(R.string.context_menu_select));
    menu.add(Menu.NONE, R.string.context_menu_package_name, Menu.NONE,
            activity.getString(R.string.context_menu_package_name));
    menu.add(Menu.NONE, R.string.context_menu_app_info, Menu.NONE,
            activity.getString(R.string.context_menu_app_info));
    PackageManager packageManager = mFragment.getActivity().getPackageManager();
    if (BuildConfig.APPLICATION_ID.equals(packageName)) {
        menu.add(Menu.NONE, R.string.context_menu_brevent_server_info, Menu.NONE,
                activity.getString(R.string.context_menu_brevent_server_info));
    } else if (packageManager.getLaunchIntentForPackage(packageName) != null) {
        menu.add(Menu.NONE, R.string.context_menu_open, Menu.NONE,
                activity.getString(R.string.context_menu_open));
    }
    if (activity.isBrevent(packageName)) {
        if (activity.isPriority(packageName)) {
            menu.add(Menu.NONE, R.string.context_menu_unset_priority, Menu.NONE,
                    activity.getString(R.string.context_menu_unset_priority));
        } else {
            menu.add(Menu.NONE, R.string.context_menu_set_priority, Menu.NONE,
                    activity.getString(R.string.context_menu_set_priority));
        }
    }
    if (activity.hasOps(packageName)) {
        menu.add(Menu.NONE, R.string.context_menu_appops, Menu.NONE,
                activity.getString(R.string.context_menu_appops));
    }
    int size = menu.size();
    for (int i = 0; i < size; ++i) {
        menu.getItem(i).setOnMenuItemClickListener(this);
    }
    String important = activity.getLabel("", packageName);
    if (!TextUtils.isEmpty(important)) {
        menu.add(AppsLabelLoader.trim(important));
    }
}
 
開發者ID:brevent,項目名稱:Brevent,代碼行數:41,代碼來源:AppsItemViewHolder.java

示例10: startAnkiDroid

import android.content.pm.PackageManager; //導入方法依賴的package包/類
public boolean startAnkiDroid() {
    PackageManager manager = mContext.getPackageManager();
    Intent i = manager.getLaunchIntentForPackage(Constant.ANKI_PACKAGE_NAME);
    if (i == null) {
        return false;
    }
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.addCategory(Intent.CATEGORY_LAUNCHER);
    mContext.startActivity(i);
    return true;
}
 
開發者ID:mmjang,項目名稱:quiz_helper,代碼行數:12,代碼來源:AnkiDroidHelper.java

示例11: openApp

import android.content.pm.PackageManager; //導入方法依賴的package包/類
/**
 * 打開包名packageName的App啟動界麵
 * @param context
 * @param packageName
 */
public void openApp(Context context,String packageName) {
    PackageManager packageManager = context.getPackageManager();
    Intent intent = packageManager.getLaunchIntentForPackage(packageName);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    context.startActivity(intent);
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:12,代碼來源:AceHelper.java

示例12: onListItemClick

import android.content.pm.PackageManager; //導入方法依賴的package包/類
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    ApkItem item = adapter.getItem(position);
    if (v.getId() == R.id.button2) {

        PackageManager pm = getActivity().getPackageManager();
        Intent intent = pm.getLaunchIntentForPackage(item.packageInfo.packageName);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    } else if (v.getId() == R.id.button3) {
        doUninstall(item);
    }
}
 
開發者ID:amikey,項目名稱:DroidPlugin,代碼行數:14,代碼來源:InstalledFragment.java

示例13: loadLabel

import android.content.pm.PackageManager; //導入方法依賴的package包/類
public String loadLabel(PackageManager packageManager, PackageInfo packageInfo) {
    long lastUpdateTime = packageInfo.lastUpdateTime;
    if (lastUpdateTime > mLastUpdateTime) {
        mLastUpdateTime = lastUpdateTime;
    }
    String packageName = packageInfo.packageName;
    if (lastUpdateTime <= mLastSync && mPreferences.contains(packageName)) {
        return mPreferences.getString(packageName, packageName);
    } else {
        Intent launchIntent = packageManager.getLaunchIntentForPackage(packageName);
        CharSequence label;
        if (launchIntent == null) {
            label = packageInfo.applicationInfo.loadLabel(packageManager);
        } else {
            label = packageManager.resolveActivity(launchIntent, 0).activityInfo
                    .loadLabel(packageManager);
        }
        if (label == null) {
            label = packageName;
        }
        String name = trim(label).toString();
        if (!label.equals(mPreferences.getString(packageName, null))) {
            mPreferences.edit().putString(packageName, name).apply();
        }
        return name;
    }
}
 
開發者ID:brevent,項目名稱:Brevent,代碼行數:28,代碼來源:AppsLabelLoader.java

示例14: c

import android.content.pm.PackageManager; //導入方法依賴的package包/類
private void c() {
    PackageManager packageManager = getPackageManager();
    String packageName = getApplicationContext().getPackageName();
    if (packageName.isEmpty()) {
        z.d(z[1], z[2]);
        return;
    }
    Intent launchIntentForPackage = packageManager.getLaunchIntentForPackage(packageName);
    if (launchIntentForPackage == null) {
        z.d(z[1], z[0]);
        return;
    }
    launchIntentForPackage.addFlags(335544320);
    startActivity(launchIntentForPackage);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:16,代碼來源:PushActivity.java

示例15: accept

import android.content.pm.PackageManager; //導入方法依賴的package包/類
public boolean accept(PackageManager pm, PackageInfo packageInfo, boolean showAllApps) {
    BreventActivity activity = getActivity();
    ApplicationInfo appInfo = packageInfo.applicationInfo;
    String packageName = packageInfo.packageName;
    // hard limit
    if (appInfo.uid < Process.FIRST_APPLICATION_UID) {
        return false;
    }
    // filter for fragment
    if (!mFragment.accept(pm, packageInfo)) {
        return false;
    }
    if (activity != null) {
        if (activity.isLauncher(packageName)) {
            // always show launcher
            return true;
        }
        if (activity.isGms(packageName)) {
            // always show gms
            return true;
        }
        if (activity.isBrevent(packageName)) {
            // always for brevented apps
            return true;
        }
    }
    if (showAllApps || mFragment.supportAllApps()) {
        // always for all apps
        return true;
    }
    return pm.getLaunchIntentForPackage(packageName) != null;
}
 
開發者ID:brevent,項目名稱:Brevent,代碼行數:33,代碼來源:AppsItemAdapter.java


注:本文中的android.content.pm.PackageManager.getLaunchIntentForPackage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。