Search in sources :

Example 96 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project facebook-android-sdk by facebook.

the class LoginManagerTest method testLogInThrowsIfCannotStartFacebookActivity.

@Test
public void testLogInThrowsIfCannotStartFacebookActivity() {
    doThrow(new ActivityNotFoundException()).when(mockActivity).startActivityForResult(any(Intent.class), anyInt());
    LoginManager loginManager = new LoginManager();
    try {
        loginManager.logInWithReadPermissions(mockActivity, Arrays.asList("public_profile", "user_friends"));
        fail();
    } catch (FacebookException exception) {
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) FacebookException(com.facebook.FacebookException) Intent(android.content.Intent) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 97 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project FBReaderJ by geometer.

the class Dictan method onActivityResult.

void onActivityResult(final FBReaderMainActivity fbreader, int resultCode, final Intent data) {
    if (data == null) {
        fbreader.hideDictionarySelection();
        return;
    }
    final int errorCode = data.getIntExtra("error.code", -1);
    if (resultCode != FBReaderMainActivity.RESULT_OK || errorCode != -1) {
        showError(fbreader, errorCode, data);
        return;
    }
    String text = data.getStringExtra("article.text");
    if (text == null) {
        showError(fbreader, -1, data);
        return;
    }
    // a hack for obsolete (before 5.0 beta) dictan versions
    final int index = text.indexOf("\000");
    if (index >= 0) {
        text = text.substring(0, index);
    }
    final boolean hasExtraData;
    if (text.length() == MAX_LENGTH_FOR_TOAST) {
        text = trimArticle(text);
        hasExtraData = true;
    } else {
        hasExtraData = data.getBooleanExtra("article.resources.contains", false);
    }
    final SuperActivityToast toast;
    if (hasExtraData) {
        toast = new SuperActivityToast(fbreader, SuperToast.Type.BUTTON);
        toast.setButtonIcon(android.R.drawable.ic_menu_more, ZLResource.resource("toast").getResource("more").getValue());
        toast.setOnClickWrapper(new OnClickWrapper("dict", new SuperToast.OnClickListener() {

            @Override
            public void onClick(View view, Parcelable token) {
                final String word = data.getStringExtra("article.word");
                final Intent intent = getActionIntent(word);
                try {
                    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                    fbreader.startActivity(intent);
                    fbreader.overridePendingTransition(0, 0);
                } catch (ActivityNotFoundException e) {
                // ignore
                }
            }
        }));
    } else {
        toast = new SuperActivityToast(fbreader, SuperToast.Type.STANDARD);
    }
    toast.setText(text);
    toast.setDuration(DictionaryUtil.TranslationToastDurationOption.getValue().Value);
    InternalUtil.showToast(toast, fbreader);
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) OnClickWrapper(com.github.johnpersano.supertoasts.util.OnClickWrapper) SuperActivityToast(com.github.johnpersano.supertoasts.SuperActivityToast) Parcelable(android.os.Parcelable) Intent(android.content.Intent) View(android.view.View)

Example 98 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project WordPress-Android by wordpress-mobile.

the class ReaderLinkMovementMethod method onTouchEvent.

@Override
public boolean onTouchEvent(@NonNull TextView textView, @NonNull Spannable buffer, @NonNull MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_UP) {
        int x = (int) event.getX();
        int y = (int) event.getY();
        x -= textView.getTotalPaddingLeft();
        y -= textView.getTotalPaddingTop();
        x += textView.getScrollX();
        y += textView.getScrollY();
        Layout layout = textView.getLayout();
        int line = layout.getLineForVertical(y);
        int off = layout.getOffsetForHorizontal(line, x);
        ImageSpan[] images = buffer.getSpans(off, off, ImageSpan.class);
        if (images != null && images.length > 0) {
            EnumSet<PhotoViewerOption> options = EnumSet.noneOf(PhotoViewerOption.class);
            if (mIsPrivate) {
                options.add(ReaderActivityLauncher.PhotoViewerOption.IS_PRIVATE_IMAGE);
            }
            String imageUrl = StringUtils.notNullStr(images[0].getSource());
            ReaderActivityLauncher.showReaderPhotoViewer(textView.getContext(), imageUrl, null, textView, options, (int) event.getX(), (int) event.getY());
            return true;
        }
    }
    try {
        return super.onTouchEvent(textView, buffer, event);
    } catch (ActivityNotFoundException e) {
        AppLog.e(AppLog.T.UTILS, e);
        return false;
    }
}
Also used : PhotoViewerOption(org.wordpress.android.ui.reader.ReaderActivityLauncher.PhotoViewerOption) Layout(android.text.Layout) ActivityNotFoundException(android.content.ActivityNotFoundException) ImageSpan(android.text.style.ImageSpan)

Example 99 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project XobotOS by xamarin.

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 100 with ActivityNotFoundException

use of android.content.ActivityNotFoundException in project XobotOS by xamarin.

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)

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