Search in sources :

Example 76 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)

Example 77 with ActivityNotFoundException

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

the class BaseStatusBar method toggleRecentsActivity.

protected void toggleRecentsActivity() {
    try {
        TaskDescription firstTask = RecentTasksLoader.getInstance(mContext).getFirstTask();
        Intent intent = new Intent(RecentsActivity.TOGGLE_RECENTS_INTENT);
        intent.setClassName("com.android.systemui", "com.android.systemui.recent.RecentsActivity");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        if (firstTask == null) {
            if (RecentsActivity.forceOpaqueBackground(mContext)) {
                ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_from_launcher_enter, R.anim.recents_launch_from_launcher_exit);
                mContext.startActivityAsUser(intent, opts.toBundle(), new UserHandle(UserHandle.USER_CURRENT));
            } else {
                // The correct window animation will be applied via the activity's style
                mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
            }
        } else {
            Bitmap first = firstTask.getThumbnail();
            final Resources res = mContext.getResources();
            float thumbWidth = res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_width);
            float thumbHeight = res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_height);
            if (first == null) {
                throw new RuntimeException("Recents thumbnail is null");
            }
            if (first.getWidth() != thumbWidth || first.getHeight() != thumbHeight) {
                first = Bitmap.createScaledBitmap(first, (int) thumbWidth, (int) thumbHeight, true);
                if (first == null) {
                    throw new RuntimeException("Recents thumbnail is null");
                }
            }
            DisplayMetrics dm = new DisplayMetrics();
            mDisplay.getMetrics(dm);
            // calculate it here, but consider moving it elsewhere
            // first, determine which orientation you're in.
            // todo: move the system_bar layouts to sw600dp ?
            final Configuration config = res.getConfiguration();
            int x, y;
            if (config.orientation == Configuration.ORIENTATION_PORTRAIT) {
                float appLabelLeftMargin = res.getDimensionPixelSize(R.dimen.status_bar_recents_app_label_left_margin);
                float appLabelWidth = res.getDimensionPixelSize(R.dimen.status_bar_recents_app_label_width);
                float thumbLeftMargin = res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_left_margin);
                float thumbBgPadding = res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_bg_padding);
                float width = appLabelLeftMargin + +appLabelWidth + thumbLeftMargin + thumbWidth + 2 * thumbBgPadding;
                x = (int) ((dm.widthPixels - width) / 2f + appLabelLeftMargin + appLabelWidth + thumbBgPadding + thumbLeftMargin);
                y = (int) (dm.heightPixels - res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_height) - thumbBgPadding);
                if (mLayoutDirection == View.LAYOUT_DIRECTION_RTL) {
                    x = dm.widthPixels - x - res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_width);
                }
            } else {
                // if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
                float thumbTopMargin = res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_top_margin);
                float thumbBgPadding = res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_bg_padding);
                float textPadding = res.getDimensionPixelSize(R.dimen.status_bar_recents_text_description_padding);
                float labelTextSize = res.getDimensionPixelSize(R.dimen.status_bar_recents_app_label_text_size);
                Paint p = new Paint();
                p.setTextSize(labelTextSize);
                float labelTextHeight = p.getFontMetricsInt().bottom - p.getFontMetricsInt().top;
                float descriptionTextSize = res.getDimensionPixelSize(R.dimen.status_bar_recents_app_description_text_size);
                p.setTextSize(descriptionTextSize);
                float descriptionTextHeight = p.getFontMetricsInt().bottom - p.getFontMetricsInt().top;
                float statusBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
                float recentsItemTopPadding = statusBarHeight;
                float height = thumbTopMargin + thumbHeight + 2 * thumbBgPadding + textPadding + labelTextHeight + recentsItemTopPadding + textPadding + descriptionTextHeight;
                float recentsItemRightPadding = res.getDimensionPixelSize(R.dimen.status_bar_recents_item_padding);
                float recentsScrollViewRightPadding = res.getDimensionPixelSize(R.dimen.status_bar_recents_right_glow_margin);
                x = (int) (dm.widthPixels - res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_width) - thumbBgPadding - recentsItemRightPadding - recentsScrollViewRightPadding);
                y = (int) ((dm.heightPixels - statusBarHeight - height) / 2f + thumbTopMargin + recentsItemTopPadding + thumbBgPadding + statusBarHeight);
            }
            ActivityOptions opts = ActivityOptions.makeThumbnailScaleDownAnimation(getStatusBarView(), first, x, y, new ActivityOptions.OnAnimationStartedListener() {

                public void onAnimationStarted() {
                    Intent intent = new Intent(RecentsActivity.WINDOW_ANIMATION_START_INTENT);
                    intent.setPackage("com.android.systemui");
                    mContext.sendBroadcastAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
                }
            });
            intent.putExtra(RecentsActivity.WAITING_FOR_WINDOW_ANIMATION_PARAM, true);
            mContext.startActivityAsUser(intent, opts.toBundle(), new UserHandle(UserHandle.USER_CURRENT));
        }
        return;
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, "Failed to launch RecentAppsIntent", e);
    }
}
Also used : Configuration(android.content.res.Configuration) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Paint(android.graphics.Paint) DisplayMetrics(android.util.DisplayMetrics) Paint(android.graphics.Paint) Bitmap(android.graphics.Bitmap) TaskDescription(com.android.systemui.recent.TaskDescription) ActivityNotFoundException(android.content.ActivityNotFoundException) UserHandle(android.os.UserHandle) Resources(android.content.res.Resources) ActivityOptions(android.app.ActivityOptions)

Example 78 with ActivityNotFoundException

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

the class PieControlPanel method launchAssistAction.

private void launchAssistAction() {
    Intent intent = getAssistIntent();
    if (intent != null) {
        try {
            ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, R.anim.search_launch_enter, R.anim.search_launch_exit);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivityAsUser(intent, opts.toBundle(), new UserHandle(UserHandle.USER_CURRENT));
        } catch (ActivityNotFoundException e) {
        }
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) UserHandle(android.os.UserHandle) Intent(android.content.Intent) ActivityOptions(android.app.ActivityOptions)

Example 79 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project k-9 by k9mail.

the class K9WebViewClient method shouldOverrideUrlLoading.

@Override
public boolean shouldOverrideUrlLoading(WebView webView, String url) {
    Uri uri = Uri.parse(url);
    if (CID_SCHEME.equals(uri.getScheme())) {
        return false;
    }
    Context context = webView.getContext();
    Intent intent = createBrowserViewIntent(uri, context);
    addActivityFlags(intent);
    boolean overridingUrlLoading = false;
    try {
        context.startActivity(intent);
        overridingUrlLoading = true;
    } catch (ActivityNotFoundException ex) {
    // If no application can handle the URL, assume that the WebView can handle it.
    }
    return overridingUrlLoading;
}
Also used : Context(android.content.Context) ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent) Uri(android.net.Uri)

Example 80 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project Jota-Text-Editor-old by jiro-aqua.

the class Main method sendDirectIntent.

private void sendDirectIntent(Intent intent) {
    if (intent == null) {
        return;
    } else {
        String substr = null;
        Editable text = mEditor.getText();
        int startsel = mEditor.getSelectionStart();
        int endsel = mEditor.getSelectionEnd();
        if (startsel != endsel) {
            if (endsel < startsel) {
                int temp = startsel;
                startsel = endsel;
                endsel = temp;
            }
            if (endsel - startsel > jp.sblo.pandora.jota.text.TextView.MAX_PARCELABLE) {
                Toast.makeText(Main.this, R.string.toast_overflow_of_limit, Toast.LENGTH_LONG).show();
                return;
            }
            substr = text.subSequence(startsel, endsel).toString();
        }
        if (intent.getAction().equals(Intent.ACTION_SEND)) {
            if (substr != null) {
                intent.putExtra(Intent.EXTRA_TEXT, substr);
            } else {
                if (text.length() <= jp.sblo.pandora.jota.text.TextView.MAX_PARCELABLE) {
                    intent.putExtra(Intent.EXTRA_TEXT, text.toString());
                } else {
                    Toast.makeText(Main.this, R.string.toast_overflow_of_limit, Toast.LENGTH_LONG).show();
                    return;
                }
            }
            try {
                startActivity(intent);
            } catch (ActivityNotFoundException e) {
            }
        } else if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
            if (substr != null) {
                intent.putExtra(SearchManager.QUERY, substr);
            } else {
                return;
            }
            try {
                startActivity(intent);
            } catch (ActivityNotFoundException e) {
            }
        } else if (intent.getAction().equals("com.adamrocker.android.simeji.ACTION_INTERCEPT")) {
            if (substr != null) {
                intent.putExtra("replace_key", substr);
            } else {
                intent.putExtra("replace_key", "");
            }
            startActivityForResult(intent, REQUESTCODE_MUSHROOM);
        } else if (intent.getAction().equals(Intent.ACTION_VIEW)) {
            if (mInstanceState.filename != null || mEditor.isChanged()) {
                mProcViewByIntent.setIntent(intent);
                confirmSave(mProcViewByIntent);
            }
        }
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) Editable(android.text.Editable)

Aggregations

ActivityNotFoundException (android.content.ActivityNotFoundException)406 Intent (android.content.Intent)365 Uri (android.net.Uri)49 PendingIntent (android.app.PendingIntent)39 View (android.view.View)39 ResolveInfo (android.content.pm.ResolveInfo)38 RecognizerIntent (android.speech.RecognizerIntent)35 PackageManager (android.content.pm.PackageManager)30 UserHandle (android.os.UserHandle)28 ComponentName (android.content.ComponentName)26 ImageView (android.widget.ImageView)24 Bundle (android.os.Bundle)23 TextView (android.widget.TextView)23 Test (org.junit.Test)23 RemoteException (android.os.RemoteException)22 Activity (android.app.Activity)21 SearchManager (android.app.SearchManager)20 DialogInterface (android.content.DialogInterface)17 SearchableInfo (android.app.SearchableInfo)15 File (java.io.File)15