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


Java ActivityNotFoundException類代碼示例

本文整理匯總了Java中android.content.ActivityNotFoundException的典型用法代碼示例。如果您正苦於以下問題:Java ActivityNotFoundException類的具體用法?Java ActivityNotFoundException怎麽用?Java ActivityNotFoundException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: setPhotoAs

import android.content.ActivityNotFoundException; //導入依賴的package包/類
public void setPhotoAs() {
    if (!(albumItem instanceof Photo)) {
        return;
    }

    Uri uri = albumItem.getUri(this);

    Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
    intent.setDataAndType(uri, MediaType.getMimeType(this, uri));
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    try {
        startActivityForResult(Intent.createChooser(intent,
                getString(R.string.set_as)), 13);
    } catch (SecurityException se) {
        Toast.makeText(this, "Error (SecurityException)", Toast.LENGTH_SHORT).show();
        se.printStackTrace();
    } catch (ActivityNotFoundException anfe) {
        Toast.makeText(this, "No App found", Toast.LENGTH_SHORT).show();
        anfe.printStackTrace();
    }
}
 
開發者ID:kollerlukas,項目名稱:Camera-Roll-Android-App,代碼行數:23,代碼來源:ItemActivity.java

示例2: sendEmail

import android.content.ActivityNotFoundException; //導入依賴的package包/類
/**
 * 發送郵件
 *
 * @param context
 * @param subject 主題
 * @param content 內容
 * @param emails  郵件地址
 */
public static void sendEmail(Context context, String subject,
                             String content, String... emails) {
    try {
        Intent intent = new Intent(Intent.ACTION_SEND);
        // 模擬器
        // intent.setType("text/plain");
        intent.setType("message/rfc822"); // 真機
        intent.putExtra(Intent.EXTRA_EMAIL, emails);
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
        intent.putExtra(Intent.EXTRA_TEXT, content);
        context.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
    }
}
 
開發者ID:snowwolf10285,項目名稱:PicShow-zhaipin,代碼行數:24,代碼來源:DeviceUtils.java

示例3: realExecStartActivity

import android.content.ActivityNotFoundException; //導入依賴的package包/類
private ActivityResult realExecStartActivity(
        Context who, IBinder contextThread, IBinder token, Activity target,
        Intent intent, int requestCode, Bundle options) {
    ActivityResult result = null;
    try {
        Class[] parameterTypes = {Context.class, IBinder.class, IBinder.class, Activity.class, Intent.class,
        int.class, Bundle.class};
        result = (ActivityResult)ReflectUtil.invoke(Instrumentation.class, mBase,
                "execStartActivity", parameterTypes,
                who, contextThread, token, target, intent, requestCode, options);
    } catch (Exception e) {
        if (e.getCause() instanceof ActivityNotFoundException) {
            throw (ActivityNotFoundException) e.getCause();
        }
        e.printStackTrace();
    }

    return result;
}
 
開發者ID:didi,項目名稱:VirtualAPK,代碼行數:20,代碼來源:VAInstrumentation.java

示例4: startCameraIntent

import android.content.ActivityNotFoundException; //導入依賴的package包/類
private void startCameraIntent(final Activity activity, final Fragment fragment, String subFolder,
                               final String action, final int requestCode) {
    final String cameraOutDir = BoxingFileHelper.getExternalDCIM(subFolder);
    try {
        if (BoxingFileHelper.createFile(cameraOutDir)) {
            mOutputFile = new File(cameraOutDir, String.valueOf(System.currentTimeMillis()) + ".jpg");
            mSourceFilePath = mOutputFile.getPath();
            Intent intent = new Intent(action);
            Uri uri = getFileUri(activity.getApplicationContext(), mOutputFile);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
            try {
                startActivityForResult(activity, fragment, intent, requestCode);
            } catch (ActivityNotFoundException ignore) {
                callbackError();
            }

        }
    } catch (ExecutionException | InterruptedException e) {
        BoxingLog.d("create file" + cameraOutDir + " error.");
    }

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:CameraPickerHelper.java

示例5: tryFacebookActivity

import android.content.ActivityNotFoundException; //導入依賴的package包/類
private boolean tryFacebookActivity(
        StartActivityDelegate startActivityDelegate,
        LoginClient.Request request) {

    Intent intent = getFacebookActivityIntent(request);

    if (!resolveIntent(intent)) {
        return false;
    }

    try {
        startActivityDelegate.startActivityForResult(
                intent,
                LoginClient.getLoginRequestCode());
    } catch (ActivityNotFoundException e) {
        return false;
    }

    return true;
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:21,代碼來源:LoginManager.java

示例6: startActivitySafely

import android.content.ActivityNotFoundException; //導入依賴的package包/類
public boolean startActivitySafely(View v, Intent intent, ItemInfo item) {
    if (mIsSafeModeEnabled && !Utilities.isSystemApp(this, intent)) {
        Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show();
        return false;
    }
    // Only launch using the new animation if the shortcut has not opted out (this is a
    // private contract between launcher and may be ignored in the future).
    boolean useLaunchAnimation = (v != null) &&
            !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
    Bundle optsBundle = useLaunchAnimation ? getActivityLaunchOptions(v) : null;

    UserHandle user = item == null ? null : item.user;

    // Prepare intent
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (v != null) {
        intent.setSourceBounds(getViewBounds(v));
    }
    try {
        if (AndroidVersion.isAtLeastMarshmallow
                && (item instanceof ShortcutInfo)
                && (item.itemType == Favorites.ITEM_TYPE_SHORTCUT
                 || item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT)
                && !((ShortcutInfo) item).isPromise()) {
            // Shortcuts need some special checks due to legacy reasons.
            startShortcutIntentSafely(intent, optsBundle, item);
        } else if (user == null || user.equals(Process.myUserHandle())) {
            // Could be launching some bookkeeping activity
            startActivity(intent, optsBundle);
        } else {
            LauncherAppsCompat.getInstance(this).startActivityForProfile(
                    intent.getComponent(), user, intent.getSourceBounds(), optsBundle);
        }
        return true;
    } catch (ActivityNotFoundException|SecurityException e) {
        Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }
    return false;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:41,代碼來源:Launcher.java

示例7: openFile

import android.content.ActivityNotFoundException; //導入依賴的package包/類
private static void openFile(Activity activity, File file, String string, View view) {

        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_VIEW);
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            Uri contentUri = FileProvider.getUriForFile(activity, activity.getApplicationContext().getPackageName() + ".provider", file);
            intent.setDataAndType(contentUri,string);

        } else {
            intent.setDataAndType(Uri.fromFile(file),string);
        }

        try {
            activity.startActivity (intent);
        } catch (ActivityNotFoundException e) {
            Snackbar.make(view, R.string.toast_install_app, Snackbar.LENGTH_LONG).show();
        }
    }
 
開發者ID:JaeNuguid,項目名稱:Kids-Portal-Android,代碼行數:22,代碼來源:helper_main.java

示例8: onDocumentPicked

import android.content.ActivityNotFoundException; //導入依賴的package包/類
@Override
public void onDocumentPicked(DocumentInfo doc) {
    final FragmentManager fm = getFragmentManager();
    if (doc.isDirectory()) {
        mState.stack.push(doc);
        mState.stackTouched = true;
        onCurrentDirectoryChanged(ANIM_DOWN);
    } else {
        // Fall back to viewing
        final Intent view = new Intent(Intent.ACTION_VIEW);
        view.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        view.setData(doc.derivedUri);
        try {
            startActivity(view);
        } catch (ActivityNotFoundException ex2) {
            Toast.makeText(this, R.string.toast_no_application, Toast.LENGTH_SHORT).show();
        }
    }
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:20,代碼來源:StandaloneActivity.java

示例9: startGoogleSearchActivity

import android.content.ActivityNotFoundException; //導入依賴的package包/類
public static void startGoogleSearchActivity(View view) {
    final Context context = view.getContext();

    final SearchManager searchManager =
            (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
    if (searchManager == null) {
        return;
    }

    ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity();
    if (globalSearchActivity == null) {
        return;
    }

    Intent intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setComponent(globalSearchActivity);

    Bundle appSearchData = new Bundle();
    appSearchData.putString("source", context.getPackageName());

    intent.putExtra(SearchManager.APP_DATA, appSearchData);
    intent.setSourceBounds(getViewBounds(view));
    try {
        context.startActivity(intent);
    } catch (ActivityNotFoundException ex) {
        ex.printStackTrace();
    }
}
 
開發者ID:OhMyLob,項目名稱:Paper-Launcher,代碼行數:30,代碼來源:IntentUtil.java

示例10: handleLocalApp

import android.content.ActivityNotFoundException; //導入依賴的package包/類
private void handleLocalApp() {
    final ComponentName component = new ComponentName(activity, SendCoinsActivity.class);
    final PackageManager pm = activity.getPackageManager();
    final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(determineBitcoinRequestStr(false)));

    try {
        // launch intent chooser with ourselves excluded
        pm.setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);
        startActivity(intent);
    } catch (final ActivityNotFoundException x) {
        new Toast(activity).longToast(R.string.request_coins_no_local_app_msg);
    } finally {
        pm.setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
                PackageManager.DONT_KILL_APP);
    }

    activity.finish();
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:20,代碼來源:RequestCoinsFragment.java

示例11: gotoWchat

import android.content.ActivityNotFoundException; //導入依賴的package包/類
public static void gotoWchat(Activity activity)
{
    try
    {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        ComponentName cmp = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.LauncherUI");
        
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setComponent(cmp);
        activity.startActivity(intent);
    }
    catch (ActivityNotFoundException e)
    {
        Toast.makeText(activity, "檢查到您手機沒有安裝微信,請安裝後使用該功能", Toast.LENGTH_LONG).show();
    }
}
 
開發者ID:zhuyu1022,項目名稱:amap,代碼行數:18,代碼來源:OsUtils.java

示例12: shareText

import android.content.ActivityNotFoundException; //導入依賴的package包/類
public static void shareText(Context context, String content, String hint) {
    if (context == null || TextUtils.isEmpty(content)) {
        return;
    }

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_TEXT, content);
    try {
        if (TextUtils.isEmpty(hint)) {
            context.startActivity(intent);
        } else {
            context.startActivity(Intent.createChooser(intent, hint));
        }
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
    }
}
 
開發者ID:homeii,項目名稱:GxIconAndroid,代碼行數:19,代碼來源:ExtraUtil.java

示例13: onMenuItemClicked

import android.content.ActivityNotFoundException; //導入依賴的package包/類
/**
 * Handles a click on the update menu item.
 * @param activity The current {@link ChromeActivity}.
 */
public void onMenuItemClicked(ChromeActivity activity) {
    if (mUpdateUrl == null) return;

    // If the update menu item is showing because it was forced on through about://flags
    // then mLatestVersion may be null.
    if (mLatestVersion != null) {
        PrefServiceBridge.getInstance().setLatestVersionWhenClickedUpdateMenuItem(
                mLatestVersion);
    }

    // Fire an intent to open the URL.
    try {
        Intent launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(mUpdateUrl));
        activity.startActivity(launchIntent);
        recordItemClickedHistogram(ITEM_CLICKED_INTENT_LAUNCHED);
        PrefServiceBridge.getInstance().setClickedUpdateMenuItem(true);
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, "Failed to launch Activity for: %s", mUpdateUrl);
        recordItemClickedHistogram(ITEM_CLICKED_INTENT_FAILED);
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:26,代碼來源:UpdateMenuItemHelper.java

示例14: onTargetNotFound

import android.content.ActivityNotFoundException; //導入依賴的package包/類
@Override
public boolean onTargetNotFound(
    @NonNull Context context,
    @NonNull Uri uri,
    @NonNull Bundle bundle,
    @Nullable Integer intentFlags) {

    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    intent.putExtras(bundle);
    if (intentFlags != null) {
        intent.setFlags(intentFlags);
    }
    try {
        context.startActivity(intent);
    } catch (ActivityNotFoundException exception) {
        exception.printStackTrace();
        return false;
    }
    return true;
}
 
開發者ID:drakeet,項目名稱:Floo,代碼行數:21,代碼來源:OpenDirectlyHandler.java

示例15: chatQQ

import android.content.ActivityNotFoundException; //導入依賴的package包/類
/**
 * qq谘詢
 */
public static boolean chatQQ(Context context, String qq) {
    try {
        if (CmdUtil.checkApkExist(context, "com.tencent.mobileqq")) {
            String url = "mqqwpa://im/chat?chat_type=wpa&uin=" + qq;
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
            return true;
        } else {
            T_.error("您沒有安裝騰訊QQ");
        }
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
        T_.error("您沒有安裝騰訊QQ");
    }
    return false;
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:21,代碼來源:RUtils.java


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