use of android.content.ActivityNotFoundException in project FBReaderJ by geometer.
the class FBUtil method shareBook.
public static void shareBook(Activity activity, Book book) {
try {
final ZLPhysicalFile file = BookUtil.fileByBook(book).getPhysicalFile();
if (file == null) {
// That should be impossible
return;
}
final CharSequence sharedFrom = Html.fromHtml(ZLResource.resource("sharing").getResource("sharedFrom").getValue());
activity.startActivity(new Intent(Intent.ACTION_SEND).setType(FileTypeCollection.Instance.rawMimeType(file).Name).putExtra(Intent.EXTRA_SUBJECT, book.getTitle()).putExtra(Intent.EXTRA_TEXT, sharedFrom).putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file.javaFile())));
} catch (ActivityNotFoundException e) {
// TODO: show toast
}
}
use of android.content.ActivityNotFoundException in project FBReaderJ by geometer.
the class OpenVideoAction method run.
@Override
protected void run(Object... params) {
if (params.length != 1 || !(params[0] instanceof ZLTextVideoRegionSoul)) {
return;
}
final ZLTextVideoElement element = ((ZLTextVideoRegionSoul) params[0]).VideoElement;
boolean playerNotFound = false;
for (MimeType mimeType : MimeType.TYPES_VIDEO) {
final String mime = mimeType.toString();
final String path = element.Sources.get(mime);
if (path == null) {
continue;
}
final Intent intent = new Intent(Intent.ACTION_VIEW);
final String url = DataUtil.buildUrl(BaseActivity.DataConnection, mime, path);
if (url == null) {
UIMessageUtil.showErrorMessage(BaseActivity, "videoServiceNotWorking");
return;
}
intent.setDataAndType(Uri.parse(url), mime);
try {
BaseActivity.startActivity(intent);
return;
} catch (ActivityNotFoundException e) {
playerNotFound = true;
continue;
}
}
if (playerNotFound) {
UIMessageUtil.showErrorMessage(BaseActivity, "videoPlayerNotFound");
}
}
use of android.content.ActivityNotFoundException in project FBReaderJ by geometer.
the class OpenWebHelpAction method run.
@Override
protected void run(Object... params) {
final String url = ZLResource.resource("links").getResource("faqPage").getValue();
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
new Thread(new Runnable() {
public void run() {
BaseActivity.runOnUiThread(new Runnable() {
public void run() {
try {
BaseActivity.startActivity(intent);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
});
}
}).start();
}
use of android.content.ActivityNotFoundException in project FBReaderJ by geometer.
the class ShowLibraryAction method run.
@Override
protected void run(Object... params) {
final Intent externalIntent = new Intent(FBReaderIntents.Action.EXTERNAL_LIBRARY);
final Intent internalIntent = new Intent(BaseActivity.getApplicationContext(), LibraryActivity.class);
if (PackageUtil.canBeStarted(BaseActivity, externalIntent, true)) {
try {
startLibraryActivity(externalIntent);
} catch (ActivityNotFoundException e) {
startLibraryActivity(internalIntent);
}
} else {
startLibraryActivity(internalIntent);
}
}
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) {
}
}
Aggregations