当前位置: 首页>>代码示例>>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;未经允许,请勿转载。