Example usage for android.content ActivityNotFoundException toString

List of usage examples for android.content ActivityNotFoundException toString

Introduction

In this page you can find the example usage for android.content ActivityNotFoundException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.phonegap.plugins.myIntent.myIntent.java

public String showSettings() {
    try {//from  w  w  w . ja v  a 2  s  . c o  m
        this.ctx.startActivity(new Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS));
        return ("OK");
    } catch (android.content.ActivityNotFoundException e) {
        System.out.println("MyIntent: Error launching settings");
        return e.toString();
    }
}

From source file:com.phonegap.plugins.pdfViewer.PdfViewer.java

public String showPdf(String fileName) {

    File file = new File(fileName);

    if (file.exists()) {
        try {/*from   www .j av  a 2 s.  c  o  m*/
            Uri path = Uri.fromFile(file);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(path, "application/pdf");
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

            //intent.setData(Uri.parse(fileName));
            this.ctx.startActivity(intent);
            return "";
        } catch (android.content.ActivityNotFoundException e) {
            System.out.println("PdfViewer: Error loading url " + fileName + ":" + e.toString());
            return e.toString();
        }

    } else {
        return "file not found";
    }
}

From source file:com.target.plugins.PdfViewer.java

public String showPdf(String fileName) {

    File file = new File(fileName);

    if (file.exists()) {
        try {//from   w w w . j av  a  2  s .c o  m
            Uri path = Uri.fromFile(file);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(path, "application/pdf");
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

            //intent.setData(Uri.parse(fileName));
            this.ctx.startActivity(intent);
            return "";
        } catch (android.content.ActivityNotFoundException e) {
            System.out.println("PdfViewer: Error loading url " + fileName + ":" + e.toString());
            return e.toString();
        }

    } else {
        return "file not found";
    }

}

From source file:com.gmail.project16543.com.phonegap.plugins.childBrowser.ChildBrowser.java

/**
 * Display a new browser with the specified URL.
 * //w  w  w. j a  v  a2 s  .  c  om
 * NOTE: If usePhoneGap is set, only trusted PhoneGap URLs should be loaded,
 * since any PhoneGap API can be called by the loaded HTML page.
 * 
 * @param url
 *            The url to load.
 * @param usePhoneGap
 *            Load url in PhoneGap webview.
 * @return "" if ok, or error message.
 */
public String showWebPage(String url, boolean usePhoneGap) {
    try {
        Intent intent = null;
        if (usePhoneGap) {
            intent = new Intent().setClass(this.ctx, com.phonegap.DroidGap.class);
            intent.setData(Uri.parse(url));
            intent.putExtra("url", url);
            intent.putExtra("loadUrlTimeoutValue", 60000);

            intent.putExtra("loadingDialog", "Wait,Loading web page...");
            intent.putExtra("hideLoadingDialogOnPageLoad", true);
        } else {
            intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(url));
        }
        this.ctx.startActivity(intent);
        return "";
    } catch (android.content.ActivityNotFoundException e) {
        System.out.println("ChildBrowser: Error loading url " + url + ":" + e.toString());
        return e.toString();
    }
}

From source file:com.jumpbyte.mobile.plugin.PdfViewer.java

public String showPdf(String fileName) {

    File file = new File(fileName);

    Log.i("PdfViewer", "open file " + fileName);
    //        if (file.exists()) {
    Log.i("PdfViewer", "file exist");
    try {/*  w  w  w . j av a  2 s  . c o m*/
        Uri path = Uri.fromFile(file);
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(path, "application/pdf");
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        //intent.setData(Uri.parse(fileName));
        this.ctx.startActivity(intent);
        return "";
    } catch (android.content.ActivityNotFoundException e) {
        System.out.println("PdfViewer: Error loading url " + fileName + ":" + e.toString());
        return e.toString();
    }
    /*
            }else{
               Log.i("PdfViewer", "file not exist");
               return "file not found";
            }
      */

}

From source file:org.jboss.aerogear.cordova.oauth2.OauthGoogleServicesIntentHelper.java

public boolean triggerIntent(final JSONObject data) throws JSONException {
    scopes = "oauth2:" + (data.has("scopes") ? data.getString("scopes") : PROFILE_SCOPE);

    final String[] accountTypes = (data.has("accountTypes")) ? data.getString("accountTypes").split("\\s")
            : new String[] { "com.google" };

    Runnable runnable = new Runnable() {
        public void run() {
            try {
                Intent intent = AccountManager.newChooseAccountIntent(null, null, accountTypes, false, null,
                        null, null, null);
                cordova.getActivity().startActivityForResult(intent, REQUEST_CODE_PICK_ACCOUNT);
            } catch (ActivityNotFoundException e) {
                Log.e(TAG, "Activity not found: " + e.toString());
                callbackContext.error("Plugin cannot find activity: " + e.toString());
            } catch (Exception e) {
                Log.e(TAG, "Exception: " + e.toString());
                callbackContext.error("Plugin failed to get account: " + e.toString());
            }/*  ww w .j av a 2 s  . c o m*/
        }

        ;
    };
    cordova.getActivity().runOnUiThread(runnable);
    return true;
}

From source file:com.xtensive.plugins.pdfviewer.PDFViewer.java

/**
  * Display a MuPDF with the specified URL.
  */*from  ww w.  j  a  v  a 2  s.  c  o  m*/
  * @param path           The path to load.
  * @return               "" if ok, or error message.
  */
public String openPDF(final String path) {
    try {

        cordova.getThreadPool().execute(new Runnable() {
            @Override
            public void run() {
                Context context = cordova.getActivity().getApplicationContext();

                Intent intent = new Intent(context, MuPDFActivity.class);
                intent.setAction(Intent.ACTION_VIEW);
                //String fileName = Environment.getExternalStorageDirectory().toString() + "/" + path;
                String fileName = path;

                Log.d(LOG_TAG, "DEBUG load: " + fileName);
                intent.setData(Uri.parse(fileName));
                cordova.getActivity().startActivityForResult(intent, XRI_LINK_CLIKED);
            }
        });

        return "";
    } catch (android.content.ActivityNotFoundException e) {

        Log.e(LOG_TAG, "Error loading url " + path + ":" + e.toString());
        return e.toString();
    }
}

From source file:com.polyvi.xface.view.XWebViewClient.java

/**
 * ?url?? url ??url//from ww  w.j  a  v a  2 s .c  o  m
 */
private boolean startSysApplication(String url) {
    Intent intent = null;
    if (url.contains("content://media/external")) {
        intent = new Intent(Intent.ACTION_PICK);
    } else {
        intent = new Intent(Intent.ACTION_VIEW);
    }
    intent.setData(Uri.parse(url));
    try {
        mSystemContext.getContext().startActivity(intent);
    } catch (ActivityNotFoundException e) {
        XLog.e(CLASS_NAME, e.toString());
    }
    return true;
}

From source file:com.polyvi.xface.view.XWebViewClient.java

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    try {/*from w  ww  . j a v  a  2  s .c o m*/
        // ?exec()?.
        if (XNativeToJsMessageQueue.ENABLE_LOCATION_CHANGE_EXEC_MODE && url.startsWith(XFACE_EXEC_URL_PREFIX)) {
            handleExecUrl(url);
        }

        XWhiteList whiteList = mWebAppView.getOwnerApp().getAppInfo().getWhiteList();
        if (url.startsWith("tel") && !XConfiguration.getInstance().isTelLinkEnabled()) {
            return true;
        }
        // TODO:??phonegap?url????
        else if (url.startsWith(XConstant.FILE_SCHEME) || url.startsWith("data:")
                || ((url.startsWith(XConstant.HTTP_SCHEME) || url.startsWith(XConstant.HTTPS_SCHEME))
                        && (null != whiteList && whiteList.isUrlWhiteListed(url)))) {
            /**
             * I9003??url? url???
             */
            return handleUrl(url);
        } else if (url.startsWith(XConstant.SCHEME_SMS)) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            // ??
            String address = null;
            int parmIndex = url.indexOf('?');
            if (-1 == parmIndex) {
                address = url.substring(XConstant.SCHEME_SMS.length());
            } else {
                address = url.substring(XConstant.SCHEME_SMS.length(), parmIndex);
                Uri uri = Uri.parse(url);
                String query = uri.getQuery();
                if (null != query) {
                    if (query.startsWith(SMS_BODY)) {
                        intent.putExtra("sms_body", query.substring(SMS_BODY.length()));
                    }
                }
            }
            intent.setData(Uri.parse(XConstant.SCHEME_SMS + address));
            intent.putExtra("address", address);
            intent.setType("vnd.android-dir/mms-sms");
            mSystemContext.getContext().startActivity(intent);
            return true;
        } else {
            // ?????
            return startSysApplication(url);
        }
    } catch (ActivityNotFoundException e) {
        XLog.e(CLASS_NAME, e.toString());
    }
    return false;
}

From source file:de.nico.asura.Main.java

private void setList() {
    ListView list = (ListView) findViewById(R.id.listView_main);
    ListAdapter adapter = new SimpleAdapter(this, downloadList, android.R.layout.simple_list_item_1,
            new String[] { TAG_NAME }, new int[] { android.R.id.text1 });
    list.setAdapter(adapter);/*from   w  w  w.  j ava  2 s .com*/

    // Do nothing when there is no Internet
    if (!(Utils.isNetworkAvailable(this))) {
        return;
    }
    // React when user click on item in the list
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View v, int pos, long id) {

            Uri downloadUri = Uri.parse(downloadList.get(pos).get(TAG_URL));
            String title = downloadList.get(pos).get(TAG_NAME);
            file = new File(Environment.getExternalStorageDirectory() + "/" + localLoc + "/"
                    + downloadList.get(pos).get(TAG_FILENAME) + ".pdf");
            Uri dest = Uri.fromFile(file);

            if (file.exists()) {
                Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
                pdfIntent.setDataAndType(dest, "application/pdf");
                pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

                try {
                    startActivity(pdfIntent);
                } catch (ActivityNotFoundException e) {
                    Utils.makeLongToast(Main.this, noPDF);
                    Log.e("ActivityNotFoundException", e.toString());
                }
                return;
            }

            // Download PDF
            Request request = new Request(downloadUri);
            request.setTitle(title).setDestinationUri(dest);
            downloadID = downloadManager.enqueue(request);
        }

    });

}