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) {
}
}
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);
}
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;
}
}
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());
}
}
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());
}
}
Aggregations