Search in sources :

Example 31 with ActivityNotFoundException

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
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) ZLPhysicalFile(org.geometerplus.zlibrary.core.filesystem.ZLPhysicalFile) Intent(android.content.Intent)

Example 32 with ActivityNotFoundException

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");
    }
}
Also used : ZLTextVideoElement(org.geometerplus.zlibrary.text.view.ZLTextVideoElement) ActivityNotFoundException(android.content.ActivityNotFoundException) ZLTextVideoRegionSoul(org.geometerplus.zlibrary.text.view.ZLTextVideoRegionSoul) Intent(android.content.Intent) MimeType(org.geometerplus.zlibrary.core.util.MimeType)

Example 33 with ActivityNotFoundException

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();
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent)

Example 34 with ActivityNotFoundException

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);
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent)

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

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