Search in sources :

Example 1 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project cw-omnibus by commonsguy.

the class MainActivity method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CONTENT_REQUEST) {
        if (resultCode == RESULT_OK) {
            Intent i = new Intent(Intent.ACTION_VIEW);
            Uri outputUri = FileProvider.getUriForFile(this, AUTHORITY, output);
            i.setDataAndType(outputUri, "image/jpeg");
            i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            try {
                startActivity(i);
            } catch (ActivityNotFoundException e) {
                Toast.makeText(this, R.string.msg_no_viewer, Toast.LENGTH_LONG).show();
            }
            finish();
        }
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent) Uri(android.net.Uri)

Example 2 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project cw-omnibus by commonsguy.

the class SearchView method onVoiceClicked.

private void onVoiceClicked() {
    // guard against possible race conditions
    if (mSearchable == null) {
        return;
    }
    SearchableInfo searchable = mSearchable;
    try {
        if (searchable.getVoiceSearchLaunchWebSearch()) {
            Intent webSearchIntent = createVoiceWebSearchIntent(mVoiceWebSearchIntent, searchable);
            getContext().startActivity(webSearchIntent);
        } else if (searchable.getVoiceSearchLaunchRecognizer()) {
            Intent appSearchIntent = createVoiceAppSearchIntent(mVoiceAppSearchIntent, searchable);
            getContext().startActivity(appSearchIntent);
        }
    } catch (ActivityNotFoundException e) {
        // Should not happen, since we check the availability of
        // voice search before showing the button. But just in case...
        Log.w(LOG_TAG, "Could not find voice search activity");
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) SearchableInfo(android.app.SearchableInfo) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent)

Example 3 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project GeekNews by codeestX.

the class AlipayUtil method startIntentUrl.

/**
     * 打开 Intent Scheme Url
     *
     * @param activity Parent Activity
     * @param intentFullUrl Intent 跳转地址
     * @return 是否成功调用
     */
public static boolean startIntentUrl(Activity activity, String intentFullUrl) {
    try {
        Intent intent = Intent.parseUri(intentFullUrl, Intent.URI_INTENT_SCHEME);
        activity.startActivity(intent);
        return true;
    } catch (URISyntaxException e) {
        e.printStackTrace();
        return false;
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
        return false;
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent) URISyntaxException(java.net.URISyntaxException)

Example 4 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project android by cSploit.

the class PortScanner method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences themePrefs = getSharedPreferences("THEME", 0);
    Boolean isDark = themePrefs.getBoolean("isDark", false);
    if (isDark)
        setTheme(R.style.DarkTheme);
    else
        setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    mPreferences = System.getSettings();
    mTextDoc = (TextView) findViewById(R.id.scanDoc);
    mTextParameters = (EditText) findViewById(R.id.scanParameters);
    mScanFloatingActionButton = (FloatingActionButton) findViewById(R.id.scanToggleButton);
    mScanProgress = (ProgressBar) findViewById(R.id.scanActivity);
    mShowCustomParameters = mPreferences.getBoolean(CUSTOM_PARAMETERS, false);
    if (mShowCustomParameters)
        displayParametersField();
    else
        hideParametersField();
    mScanFloatingActionButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mRunning) {
                setStoppedState();
            } else {
                setStartedState();
            }
        }
    });
    ListView mScanList = (ListView) findViewById(R.id.scanListView);
    createPortList();
    final Target target = System.getCurrentTarget();
    final String cmdlineRep = target.getCommandLineRepresentation();
    mScanReceiver = new Receiver(target);
    mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mPortList);
    mScanList.setAdapter(mListAdapter);
    mScanList.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            int portNumber = target.getOpenPorts().get(position).getNumber();
            if (!urlFormats.containsKey(portNumber)) {
                portNumber = 0;
            }
            final String url = String.format(urlFormats.get(portNumber), cmdlineRep, portNumber);
            new ConfirmDialog("Open", "Open " + url + " ?", PortScanner.this, new ConfirmDialogListener() {

                @Override
                public void onConfirm() {
                    try {
                        Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                        PortScanner.this.startActivity(browser);
                    } catch (ActivityNotFoundException e) {
                        System.errorLogging(e);
                        new ErrorDialog(getString(R.string.error), getString(R.string.no_activities_for_url), PortScanner.this).show();
                    }
                }

                @Override
                public void onCancel() {
                }
            }).show();
            return false;
        }
    });
}
Also used : SharedPreferences(android.content.SharedPreferences) ErrorDialog(org.csploit.android.gui.dialogs.ErrorDialog) Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) Target(org.csploit.android.net.Target) ListView(android.widget.ListView) ActivityNotFoundException(android.content.ActivityNotFoundException) OnClickListener(android.view.View.OnClickListener) ConfirmDialogListener(org.csploit.android.gui.dialogs.ConfirmDialog.ConfirmDialogListener) ConfirmDialog(org.csploit.android.gui.dialogs.ConfirmDialog)

Example 5 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project OneClickAndroid by cyngn.

the class UsbActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    OneClickStats.sendEvent(this, OneClickStats.Categories.PAGE_SHOWN, OneClickStats.Actions.PAGE_ADB);
    if (adbIsEnabled()) {
        startActivity(new Intent(getBaseContext(), PtpActivity.class));
        finish();
        return;
    }
    setContentView(R.layout.usb);
    ImageView instructionView = (ImageView) findViewById(R.id.usb_instructions);
    DecelerateInterpolator interpolator = new DecelerateInterpolator(2.0f);
    AnimationSet instructionAnimations = new AnimationSet(true);
    instructionAnimations.setInterpolator(interpolator);
    TranslateAnimation instructionMoveAnimation = new TranslateAnimation(0, 0, 250, 0);
    instructionMoveAnimation.setDuration(1000);
    instructionMoveAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
    instructionAnimations.addAnimation(instructionMoveAnimation);
    // we want them to read the instructions first! so we give them a few seconds
    AlphaAnimation instructionFadeAnimation = new AlphaAnimation(0.0f, 1.0f);
    instructionFadeAnimation.setDuration(1000);
    instructionFadeAnimation.setStartOffset(500);
    instructionFadeAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
    instructionAnimations.addAnimation(instructionFadeAnimation);
    instructionView.setAnimation(instructionAnimations);
    // continue button should take even longer
    AlphaAnimation buttonAnimation = new AlphaAnimation(0.0f, 1.0f);
    buttonAnimation.setDuration(750);
    buttonAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
    buttonAnimation.setStartOffset(1000);
    findViewById(R.id.next).setAnimation(buttonAnimation);
    OnClickListener openUsbListener = new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent();
            intent.setClassName("com.android.settings", "com.android.settings.DevelopmentSettings");
            try {
                OneClickStats.sendEvent(view.getContext(), OneClickStats.Categories.BUTTON_CLICK, OneClickStats.Actions.BTN_ADB);
                startActivity(intent);
                startService(new Intent(getBaseContext(), UsbDebuggingMonitorService.class));
            } catch (ActivityNotFoundException e) {
                // we want to know if this happens, right?
                OneClickStats.sendEvent(view.getContext(), OneClickStats.Categories.SWITCH_ERROR, OneClickStats.Actions.ERR_ADB);
            }
        }
    };
    findViewById(R.id.next).setOnClickListener(openUsbListener);
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ActivityNotFoundException(android.content.ActivityNotFoundException) TranslateAnimation(android.view.animation.TranslateAnimation) OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) ImageView(android.widget.ImageView) AnimationSet(android.view.animation.AnimationSet) ImageView(android.widget.ImageView) View(android.view.View) AlphaAnimation(android.view.animation.AlphaAnimation)

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