Search in sources :

Example 11 with ActivityNotFoundException

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

the class Credentials method unlock.

public void unlock(Context context) {
    try {
        Intent intent = new Intent(UNLOCK_ACTION);
        context.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Log.w(LOGTAG, e.toString());
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent)

Example 12 with ActivityNotFoundException

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

the class Credentials method install.

public void install(Context context) {
    try {
        Intent intent = KeyChain.createInstallIntent();
        context.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Log.w(LOGTAG, e.toString());
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent)

Example 13 with ActivityNotFoundException

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

the class Credentials method install.

public void install(Context context, KeyPair pair) {
    try {
        Intent intent = KeyChain.createInstallIntent();
        intent.putExtra(EXTRA_PRIVATE_KEY, pair.getPrivate().getEncoded());
        intent.putExtra(EXTRA_PUBLIC_KEY, pair.getPublic().getEncoded());
        context.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Log.w(LOGTAG, e.toString());
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent)

Example 14 with ActivityNotFoundException

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

the class AudioService method startVoiceBasedInteractions.

/**
     * Tell the system to start voice-based interactions / voice commands
     */
private void startVoiceBasedInteractions(boolean needWakeLock) {
    Intent voiceIntent = null;
    // select which type of search to launch:
    // - screen on and device unlocked: action is ACTION_WEB_SEARCH
    // - device locked or screen off: action is ACTION_VOICE_SEARCH_HANDS_FREE
    //    with EXTRA_SECURE set to true if the device is securely locked
    PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
    boolean isLocked = mKeyguardManager != null && mKeyguardManager.isKeyguardLocked();
    if (!isLocked && pm.isScreenOn()) {
        voiceIntent = new Intent(android.speech.RecognizerIntent.ACTION_WEB_SEARCH);
        Log.i(TAG, "voice-based interactions: about to use ACTION_WEB_SEARCH");
    } else {
        voiceIntent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE);
        voiceIntent.putExtra(RecognizerIntent.EXTRA_SECURE, isLocked && mKeyguardManager.isKeyguardSecure());
        Log.i(TAG, "voice-based interactions: about to use ACTION_VOICE_SEARCH_HANDS_FREE");
    }
    // start the search activity
    if (needWakeLock) {
        mMediaEventWakeLock.acquire();
    }
    try {
        if (voiceIntent != null) {
            voiceIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            mContext.startActivity(voiceIntent);
        }
    } catch (ActivityNotFoundException e) {
        Log.w(TAG, "No activity for search: " + e);
    } finally {
        if (needWakeLock) {
            mMediaEventWakeLock.release();
        }
    }
}
Also used : PowerManager(android.os.PowerManager) ActivityNotFoundException(android.content.ActivityNotFoundException) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent)

Example 15 with ActivityNotFoundException

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

the class SearchPanelView method startAssistActivity.

private void startAssistActivity() {
    if (!mBar.isDeviceProvisioned())
        return;
    // Close Recent Apps if needed
    mBar.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL);
    boolean isKeyguardShowing = false;
    try {
        isKeyguardShowing = mWm.isKeyguardLocked();
    } catch (RemoteException e) {
    }
    if (isKeyguardShowing) {
        // Have keyguard show the bouncer and launch the activity if the user succeeds.
        try {
            mWm.showAssistant();
        } catch (RemoteException e) {
        // too bad, so sad...
        }
        onAnimationStarted();
    } else {
        // Otherwise, keyguard isn't showing so launch it from here.
        Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)).getAssistIntent(mContext, true, UserHandle.USER_CURRENT);
        if (intent == null)
            return;
        try {
            ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
        } catch (RemoteException e) {
        // too bad, so sad...
        }
        try {
            ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, R.anim.search_launch_enter, R.anim.search_launch_exit, getHandler(), this);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivityAsUser(intent, opts.toBundle(), new UserHandle(UserHandle.USER_CURRENT));
        } catch (ActivityNotFoundException e) {
            Slog.w(TAG, "Activity not found for " + intent.getAction());
            onAnimationStarted();
        }
    }
}
Also used : SearchManager(android.app.SearchManager) ActivityNotFoundException(android.content.ActivityNotFoundException) UserHandle(android.os.UserHandle) Intent(android.content.Intent) RemoteException(android.os.RemoteException) ActivityOptions(android.app.ActivityOptions)

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