Search in sources :

Example 21 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project android_frameworks_base by ParanoidAndroid.

the class BackupManagerService method startConfirmationUi.

boolean startConfirmationUi(int token, String action) {
    try {
        Intent confIntent = new Intent(action);
        confIntent.setClassName("com.android.backupconfirm", "com.android.backupconfirm.BackupRestoreConfirmation");
        confIntent.putExtra(FullBackup.CONF_TOKEN_INTENT_EXTRA, token);
        confIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mContext.startActivity(confIntent);
    } catch (ActivityNotFoundException e) {
        return false;
    }
    return true;
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent)

Example 22 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project android_frameworks_base by ParanoidAndroid.

the class ConnectivityService method handleMobileProvisioningAction.

private void handleMobileProvisioningAction(String url) {
    // Notication mark notification as not visible
    setProvNotificationVisible(false, ConnectivityManager.TYPE_NONE, null, null);
    // If provisioning network handle as a special case,
    // otherwise launch browser with the intent directly.
    NetworkInfo ni = getProvisioningNetworkInfo();
    if ((ni != null) && ni.isConnectedToProvisioningNetwork()) {
        if (DBG)
            log("handleMobileProvisioningAction: on provisioning network");
        MobileDataStateTracker mdst = (MobileDataStateTracker) mNetTrackers[ConnectivityManager.TYPE_MOBILE];
        mdst.enableMobileProvisioning(url);
    } else {
        if (DBG)
            log("handleMobileProvisioningAction: on default network");
        Intent newIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        newIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
        try {
            mContext.startActivity(newIntent);
        } catch (ActivityNotFoundException e) {
            loge("handleMobileProvisioningAction: startActivity failed" + e);
        }
    }
}
Also used : NetworkInfo(android.net.NetworkInfo) ActivityNotFoundException(android.content.ActivityNotFoundException) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) MobileDataStateTracker(android.net.MobileDataStateTracker)

Example 23 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project android_frameworks_base by ParanoidAndroid.

the class ActivityManagerService method crashApplication.

/**
     * Bring up the "unexpected error" dialog box for a crashing app.
     * Deal with edge cases (intercepts from instrumented applications,
     * ActivityController, error intent receivers, that sort of thing).
     * @param r the application crashing
     * @param crashInfo describing the failure
     */
private void crashApplication(ProcessRecord r, ApplicationErrorReport.CrashInfo crashInfo) {
    long timeMillis = System.currentTimeMillis();
    String shortMsg = crashInfo.exceptionClassName;
    String longMsg = crashInfo.exceptionMessage;
    String stackTrace = crashInfo.stackTrace;
    if (shortMsg != null && longMsg != null) {
        longMsg = shortMsg + ": " + longMsg;
    } else if (shortMsg != null) {
        longMsg = shortMsg;
    }
    AppErrorResult result = new AppErrorResult();
    synchronized (this) {
        if (mController != null) {
            try {
                String name = r != null ? r.processName : null;
                int pid = r != null ? r.pid : Binder.getCallingPid();
                if (!mController.appCrashed(name, pid, shortMsg, longMsg, timeMillis, crashInfo.stackTrace)) {
                    Slog.w(TAG, "Force-killing crashed app " + name + " at watcher's request");
                    Process.killProcess(pid);
                    return;
                }
            } catch (RemoteException e) {
                mController = null;
                Watchdog.getInstance().setActivityController(null);
            }
        }
        final long origId = Binder.clearCallingIdentity();
        // If this process is running instrumentation, finish it.
        if (r != null && r.instrumentationClass != null) {
            Slog.w(TAG, "Error in app " + r.processName + " running instrumentation " + r.instrumentationClass + ":");
            if (shortMsg != null)
                Slog.w(TAG, "  " + shortMsg);
            if (longMsg != null)
                Slog.w(TAG, "  " + longMsg);
            Bundle info = new Bundle();
            info.putString("shortMsg", shortMsg);
            info.putString("longMsg", longMsg);
            finishInstrumentationLocked(r, Activity.RESULT_CANCELED, info);
            Binder.restoreCallingIdentity(origId);
            return;
        }
        // quit right away without showing a crash dialog.
        if (r == null || !makeAppCrashingLocked(r, shortMsg, longMsg, stackTrace)) {
            Binder.restoreCallingIdentity(origId);
            return;
        }
        Message msg = Message.obtain();
        msg.what = SHOW_ERROR_MSG;
        HashMap data = new HashMap();
        data.put("result", result);
        data.put("app", r);
        msg.obj = data;
        mHandler.sendMessage(msg);
        Binder.restoreCallingIdentity(origId);
    }
    int res = result.get();
    Intent appErrorIntent = null;
    synchronized (this) {
        if (r != null && !r.isolated) {
            // XXX Can't keep track of crash time for isolated processes,
            // since they don't have a persistent identity.
            mProcessCrashTimes.put(r.info.processName, r.uid, SystemClock.uptimeMillis());
        }
        if (res == AppErrorDialog.FORCE_QUIT_AND_REPORT) {
            appErrorIntent = createAppErrorIntentLocked(r, timeMillis, crashInfo);
        }
    }
    if (appErrorIntent != null) {
        try {
            mContext.startActivityAsUser(appErrorIntent, new UserHandle(r.userId));
        } catch (ActivityNotFoundException e) {
            Slog.w(TAG, "bug report receiver dissappeared", e);
        }
    }
}
Also used : Message(android.os.Message) HashMap(java.util.HashMap) ActivityNotFoundException(android.content.ActivityNotFoundException) Bundle(android.os.Bundle) UserHandle(android.os.UserHandle) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) RemoteException(android.os.RemoteException)

Example 24 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project android_frameworks_base by ParanoidAndroid.

the class UsbDebuggingManager method showConfirmationDialog.

private void showConfirmationDialog(String key, String fingerprints) {
    Intent dialogIntent = new Intent();
    dialogIntent.setClassName("com.android.systemui", "com.android.systemui.usb.UsbDebuggingActivity");
    dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    dialogIntent.putExtra("key", key);
    dialogIntent.putExtra("fingerprints", fingerprints);
    try {
        mContext.startActivity(dialogIntent);
    } catch (ActivityNotFoundException e) {
        Slog.e(TAG, "unable to start UsbDebuggingActivity");
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent)

Example 25 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project SeriesGuide by UweTrottmann.

the class ShareUtils method startShareIntentChooser.

/**
     * Share a text snippet. Displays a share intent chooser with the given title, share type is
     * text/plain.
     */
public static void startShareIntentChooser(Activity activity, String message, @StringRes int titleResId) {
    IntentBuilder ib = ShareCompat.IntentBuilder.from(activity);
    ib.setText(message);
    ib.setChooserTitle(titleResId);
    ib.setType("text/plain");
    try {
        ib.startChooser();
    } catch (ActivityNotFoundException e) {
        // no activity available to handle the intent
        Toast.makeText(activity, R.string.app_not_available, Toast.LENGTH_LONG).show();
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) IntentBuilder(android.support.v4.app.ShareCompat.IntentBuilder)

Aggregations

ActivityNotFoundException (android.content.ActivityNotFoundException)384 Intent (android.content.Intent)343 Uri (android.net.Uri)45 View (android.view.View)38 PendingIntent (android.app.PendingIntent)37 RecognizerIntent (android.speech.RecognizerIntent)35 ResolveInfo (android.content.pm.ResolveInfo)33 UserHandle (android.os.UserHandle)28 ComponentName (android.content.ComponentName)24 PackageManager (android.content.pm.PackageManager)23 Bundle (android.os.Bundle)23 ImageView (android.widget.ImageView)23 RemoteException (android.os.RemoteException)22 TextView (android.widget.TextView)22 SearchManager (android.app.SearchManager)20 SearchableInfo (android.app.SearchableInfo)15 File (java.io.File)15 DialogInterface (android.content.DialogInterface)14 AlertDialog (android.app.AlertDialog)13 Context (android.content.Context)13