List of usage examples for android.content ActivityNotFoundException printStackTrace
public void printStackTrace()
From source file:de.blinkt.openvpn.ActivityDashboard.java
public boolean permissionConnect() { // delete the vpn log. File file = new File(getCacheDir(), "vpnlog.txt"); if (file.exists()) file.delete();/*from www. j a v a2 s .c om*/ Intent intent = VpnService.prepare(this); if (intent != null) { try { startActivityForResult(intent, 0); } catch (ActivityNotFoundException e) { e.printStackTrace(); return false; } } else { onActivityResult(0, Activity.RESULT_OK, null); } return true; }
From source file:og.android.tether.MainActivity.java
/** Called when the activity is first created. */ @TargetApi(4)//from www .j a v a 2s . c o m @Override public void onCreate(Bundle savedInstanceState) { Log.d(MSG_TAG, "Calling onCreate()"); super.onCreate(savedInstanceState); setContentView(R.layout.main); // Init Application this.application = (TetherApplication) this.getApplication(); MainActivity.setCurrent(this); // Init Table-Rows this.startTblRow = (TableRow) findViewById(R.id.startRow); this.stopTblRow = (TableRow) findViewById(R.id.stopRow); this.radioModeImage = (ImageView) findViewById(R.id.radioModeImage); this.progressBar = (ProgressBar) findViewById(R.id.progressBar); this.progressText = (TextView) findViewById(R.id.progressText); this.progressTitle = (TextView) findViewById(R.id.progressTitle); this.downloadUpdateLayout = (RelativeLayout) findViewById(R.id.layoutDownloadUpdate); this.batteryTemperatureLayout = (RelativeLayout) findViewById(R.id.layoutBatteryTemp); this.lockButtonCheckbox = (CheckBox) findViewById(R.id.lockButton); this.trafficRow = (RelativeLayout) findViewById(R.id.trafficRow); this.downloadText = (TextView) findViewById(R.id.trafficDown); this.uploadText = (TextView) findViewById(R.id.trafficUp); this.downloadRateText = (TextView) findViewById(R.id.trafficDownRate); this.uploadRateText = (TextView) findViewById(R.id.trafficUpRate); this.batteryTemperature = (TextView) findViewById(R.id.batteryTempText); // Define animation animation = new ScaleAnimation(0.9f, 1, 0.9f, 1, // From x, to x, from y, to y ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(600); animation.setFillAfter(true); animation.setStartOffset(0); animation.setRepeatCount(1); animation.setRepeatMode(Animation.REVERSE); if (this.application.startupCheckPerformed == false) { if (this.application.settings.getLong("install_timestamp", -1) == -1) { long t = System.currentTimeMillis() / 1000; this.application.preferenceEditor.putLong("install_timestamp", t); } } this.application.reportStats(-1, false); // open ad bar openAdBar(); // Startup-Check if (this.application.startupCheckPerformed == false) { this.application.startupCheckPerformed = true; String regId = C2DMessaging.getRegistrationId(this); boolean registered = this.application.settings.getBoolean("c2dm_registered", false); if (!registered || regId == null || "".equals(regId)) { Log.d(MSG_TAG, "C2DM Registering"); C2DMessaging.register(this, DeviceRegistrar.SENDER_ID); } else { Log.d(MSG_TAG, "C2DM already registered"); } // Check if required kernel-features are enabled if (!this.application.coretask.isNetfilterSupported()) { this.openNoNetfilterDialog(); this.application.accessControlSupported = false; this.application.whitelist.remove(); } else { // Check if access-control-feature is supported by kernel if (!this.application.coretask.isAccessControlSupported()) { if (this.application.settings.getBoolean("warning_noaccesscontrol_displayed", false) == false) { this.openNoAccessControlDialog(); this.application.preferenceEditor.putBoolean("warning_noaccesscontrol_displayed", true); this.application.preferenceEditor.commit(); } this.application.accessControlSupported = false; this.application.whitelist.remove(); } } // Check if binaries need to be updated if (this.application.binariesExists() == false || this.application.coretask.filesetOutdated()) { if (this.application.coretask.hasRootPermission()) { this.application.installFiles(); } } // Open donate-dialog this.openDonateDialog(); // Check for updates this.application.checkForUpdate(); } // Check root-permission, files if (!this.application.coretask.hasRootPermission()) openLaunchedDialog(true); this.rssReader = new RSSReader(getApplicationContext(), TetherApplication.FORUM_RSS_URL); this.rssView = (ListView) findViewById(R.id.RSSView); this.rssAdapter = new ArrayAdapter<Spanned>(this, R.layout.rss_item); this.rssView.setAdapter(this.rssAdapter); this.rssView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Log.d(MSG_TAG, parent + ":" + view + ":" + position + ":" + id); MainActivity.this.application.statRSSClicks(); String url = null; try { url = MainActivity.this.jsonRssArray.getJSONObject(position).getString("link"); } catch (JSONException e) { url = TetherApplication.FORUM_URL; } url = tagURL(url, "android", "rss", "community"); Intent viewRssLink = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url)); try { startActivity(viewRssLink); } catch (ActivityNotFoundException e) { url = tagURL(TetherApplication.FORUM_URL, "android", "rss", "community"); viewRssLink = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url)); try { startActivity(viewRssLink); } catch (ActivityNotFoundException e2) { e2.printStackTrace(); } } } }); this.rssPanel = (Panel) findViewById(R.id.RSSPanel); this.rssPanel.setInterpolator(new BounceInterpolator()); this.rssPanel.setOnPanelListener(new OnPanelListener() { public void onPanelClosed(Panel panel) { hideCommunityText(true); MainActivity.this.application.preferenceEditor.putBoolean("rss_closed", true).commit(); } public void onPanelOpened(Panel panel) { hideCommunityText(false); MainActivity.this.application.preferenceEditor.putBoolean("rss_closed", false).commit(); } }); this.communityText = (TextView) findViewById(R.id.communityHeader); this.communityText.setOnClickListener(new OnClickListener() { public void onClick(View v) { MainActivity.this.rssPanel.setOpen(!MainActivity.this.rssPanel.isOpen(), true); } }); hideCommunityText(!this.rssPanel.isOpen()); this.bottomButtonLayout = (LinearLayout) findViewById(R.id.bottomButtonLayout); ((Button) findViewById(R.id.anchorLinkButton)).setOnClickListener(new OnClickListener() { public void onClick(View v) { startGooglePlayMeshclient("nonroot_tether"); } }); ((Button) findViewById(R.id.configButton)).setOnClickListener(new OnClickListener() { public void onClick(View v) { startActivityForResult(new Intent(MainActivity.this, SetupActivity.class).setAction("FOO"), 33); } }); // Start Button this.startBtn = (ImageView) findViewById(R.id.startTetherBtn); this.startBtnListener = new OnClickListener() { public void onClick(View v) { Log.d(MSG_TAG, "StartBtn pressed ..."); new Thread(new Runnable() { public void run() { Intent intent = new Intent(TetherService.INTENT_MANAGE); intent.putExtra("state", TetherService.MANAGE_START); Log.d(MSG_TAG, "SENDING MANAGE: " + intent); MainActivity.this.sendBroadcast(intent); } }).start(); } }; this.startBtn.setOnClickListener(this.startBtnListener); // Stop Button this.stopBtn = (ImageView) findViewById(R.id.stopTetherBtn); this.stopBtnListener = new OnClickListener() { public void onClick(View v) { Log.d(MSG_TAG, "StopBtn pressed ..."); if (MainActivity.this.lockBtn.isChecked()) { Log.d(MSG_TAG, "Tether was locked ..."); MainActivity.this.application.displayToastMessage(getString(R.string.main_activity_locked)); return; } new Thread(new Runnable() { public void run() { Intent intent = new Intent(TetherService.INTENT_MANAGE); intent.setAction(TetherService.INTENT_MANAGE); intent.putExtra("state", TetherService.MANAGE_STOP); Log.d(MSG_TAG, "Sending Intent: " + intent); MainActivity.this.sendBroadcast(intent); } }).start(); } }; this.stopBtn.setOnClickListener(this.stopBtnListener); this.lockBtn = (CompoundButton) findViewById(R.id.lockButton); this.lockBtnListener = new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Log.d(MSG_TAG, "LockBtn pressed ..."); } }; this.lockBtn.setOnCheckedChangeListener(this.lockBtnListener); // Toggles between start and stop screen this.toggleStartStop(); }
From source file:br.com.anteros.vendas.gui.AnexoCadastroActivity.java
/** * Abre o anexo pela URI do arquivo anexado para visualizao. * @param mUri/* www . j ava2 s .c om*/ */ private void abrirAnexo(Uri mUri) { String extension = FilenameUtils.getExtension(AndroidFileUtils.getPath(AnexoCadastroActivity.this, mUri)); try { Intent intent = new Intent(Intent.ACTION_VIEW); MimeTypeMap mime = MimeTypeMap.getSingleton(); String type = mime.getMimeTypeFromExtension(extension); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(mUri, type); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getApplicationContext().startActivity(intent); } catch (ActivityNotFoundException e) { new ErrorAlert(AnexoCadastroActivity.this, getResources().getString(R.string.app_name), "No foi encontrado nenhum aplicativo nesse aparelho que suporte abrir a extenso '" + extension + "', entre em contato com a equipe de Suporte para resolver esse problema.").show(); } catch (Exception e) { new ErrorAlert(AnexoCadastroActivity.this, getResources().getString(R.string.app_name), "No foi possvel abrir o anexo " + anexo.getId() + ". " + e.getMessage()).show(); e.printStackTrace(); } }
From source file:com.amaze.filemanager.utils.Futils.java
public void openunknown(File f, Context c, boolean forcechooser) { Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); String type = MimeTypes.getMimeType(f); if (type != null && type.trim().length() != 0 && !type.equals("*/*")) { Uri uri = fileToContentUri(c, f); if (uri == null) uri = Uri.fromFile(f);//w w w . j a v a 2 s.co m intent.setDataAndType(uri, type); Intent startintent; if (forcechooser) startintent = Intent.createChooser(intent, c.getResources().getString(R.string.openwith)); else startintent = intent; try { c.startActivity(startintent); } catch (ActivityNotFoundException e) { e.printStackTrace(); Toast.makeText(c, R.string.noappfound, Toast.LENGTH_SHORT).show(); openWith(f, c); } } else { openWith(f, c); } }
From source file:com.amaze.filemanager.fragments.Main.java
private void launch(final SmbFile smbFile, final long si) { s = Streamer.getInstance();/*from ww w. jav a 2 s . com*/ new Thread() { public void run() { try { s.setStreamSrc(smbFile, null, si);//the second argument can be a list of subtitle files getActivity().runOnUiThread(new Runnable() { public void run() { try { Uri uri = Uri.parse(Streamer.URL + Uri.fromFile(new File(Uri.parse(smbFile.getPath()).getPath())) .getEncodedPath()); Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(uri, MimeTypes.getMimeType(new File(smbFile.getPath()))); PackageManager packageManager = getActivity().getPackageManager(); List<ResolveInfo> resInfos = packageManager.queryIntentActivities(i, 0); if (resInfos != null && resInfos.size() > 0) startActivity(i); else Toast.makeText(getActivity(), "You will need to copy this file to storage to open it", Toast.LENGTH_SHORT).show(); } catch (ActivityNotFoundException e) { e.printStackTrace(); } } }); } catch (Exception e) { e.printStackTrace(); } } }.start(); }
From source file:au.com.infiniterecursion.vidiom.utils.PublishingUtils.java
public void launchVideoPlayer(final Activity activity, final String moviePath) { try {// w w w . jav a2 s. com Intent tostart = new Intent(Intent.ACTION_VIEW); tostart.setDataAndType(Uri.parse("file://" + moviePath), "video/*"); activity.startActivity(tostart); } catch (android.content.ActivityNotFoundException e) { Log.e(TAG, " Cant start activity to show video!"); e.printStackTrace(); new AlertDialog.Builder(activity).setMessage(R.string.cant_show_video) .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }).show(); return; } }
From source file:com.zertinteractive.wallpaper.MainActivity.java
public void openUri(String uri) { try {/*from w ww . j a v a2 s .c o m*/ Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); startActivity(myIntent); } catch (ActivityNotFoundException e) { Toast.makeText(this, "No application can handle this request." + " Please install necessary application", Toast.LENGTH_LONG).show(); e.printStackTrace(); } }
From source file:com.ichi2.anki.AbstractFlashcardViewer.java
@SuppressLint({ "NewApi", "SetJavaScriptEnabled" }) // because of setDisplayZoomControls. private WebView createWebView() { WebView webView = new MyWebView(this); webView.setWillNotCacheDrawing(true); webView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); if (CompatHelper.isHoneycomb()) { // Disable the on-screen zoom buttons for API > 11 webView.getSettings().setDisplayZoomControls(false); }/* w w w . j a v a 2 s . c o m*/ webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setSupportZoom(true); // Start at the most zoomed-out level webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setJavaScriptEnabled(true); webView.setWebChromeClient(new AnkiDroidWebChromeClient()); // Problems with focus and input tags is the reason we keep the old type answer mechanism for old Androids. webView.setFocusableInTouchMode(mUseInputTag); webView.setScrollbarFadingEnabled(true); Timber.d("Focusable = %s, Focusable in touch mode = %s", webView.isFocusable(), webView.isFocusableInTouchMode()); webView.setWebViewClient(new WebViewClient() { // Filter any links using the custom "playsound" protocol defined in Sound.java. // We play sounds through these links when a user taps the sound icon. @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.startsWith("playsound:")) { // Send a message that will be handled on the UI thread. Message msg = Message.obtain(); String soundPath = url.replaceFirst("playsound:", ""); msg.obj = soundPath; mHandler.sendMessage(msg); return true; } if (url.startsWith("file") || url.startsWith("data:")) { return false; // Let the webview load files, i.e. local images. } if (url.startsWith("typeblurtext:")) { // Store the text the javascript has send us mTypeInput = URLDecoder.decode(url.replaceFirst("typeblurtext:", "")); // and show the SHOW ANSWER? button again. mFlipCardLayout.setVisibility(View.VISIBLE); return true; } if (url.startsWith("typeentertext:")) { // Store the text the javascript has send us mTypeInput = URLDecoder.decode(url.replaceFirst("typeentertext:", "")); // and show the answer. mFlipCardLayout.performClick(); return true; } if (url.equals("signal:typefocus")) { // Hide the SHOW ANSWER? button when the input has focus. The soft keyboard takes up enough space // by itself. mFlipCardLayout.setVisibility(View.GONE); return true; } Timber.d("Opening external link \"%s\" with an Intent", url); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); try { startActivityWithoutAnimation(intent); } catch (ActivityNotFoundException e) { e.printStackTrace(); // Don't crash if the intent is not handled } return true; } // Run any post-load events in javascript that rely on the window being completely loaded. @Override public void onPageFinished(WebView view, String url) { Timber.d("onPageFinished triggered"); view.loadUrl("javascript:onPageFinished();"); } }); // Set transparent color to prevent flashing white when night mode enabled webView.setBackgroundColor(Color.argb(1, 0, 0, 0)); return webView; }
From source file:com.mozilla.SUTAgentAndroid.service.DoCommand.java
public String StartJavaPrg(String[] sArgs, Intent preIntent) { String sRet = ""; String sArgList = ""; String sUrl = ""; // String sRedirFileName = ""; Intent prgIntent = null;//from w w w . j a va 2s. co m Context ctx = contextWrapper.getApplicationContext(); PackageManager pm = ctx.getPackageManager(); if (preIntent == null) prgIntent = new Intent(); else prgIntent = preIntent; prgIntent.setPackage(sArgs[0]); prgIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Get the main activity for this package try { final ComponentName c = pm.getLaunchIntentForPackage(sArgs[0]).getComponent(); prgIntent.setClassName(c.getPackageName(), c.getClassName()); } catch (Exception e) { e.printStackTrace(); return "Unable to find main activity for package: " + sArgs[0]; } if (sArgs.length > 1) { if (sArgs[0].contains("android.browser")) prgIntent.setAction(Intent.ACTION_VIEW); else prgIntent.setAction(Intent.ACTION_MAIN); if (sArgs[0].contains("fennec") || sArgs[0].contains("firefox")) { sArgList = ""; sUrl = ""; for (int lcv = 1; lcv < sArgs.length; lcv++) { if (sArgs[lcv].contains("://")) { prgIntent.setAction(Intent.ACTION_VIEW); sUrl = sArgs[lcv]; } else { if (sArgs[lcv].equals(">")) { lcv++; if (lcv < sArgs.length) lcv++; // sRedirFileName = sArgs[lcv++]; } else sArgList += " " + sArgs[lcv]; } } if (sArgList.length() > 0) prgIntent.putExtra("args", sArgList.trim()); if (sUrl.length() > 0) prgIntent.setData(Uri.parse(sUrl.trim())); } else { for (int lcv = 1; lcv < sArgs.length; lcv++) sArgList += " " + sArgs[lcv]; prgIntent.setData(Uri.parse(sArgList.trim())); } } else { prgIntent.setAction(Intent.ACTION_MAIN); } try { contextWrapper.startActivity(prgIntent); FindProcThread findProcThrd = new FindProcThread(contextWrapper, sArgs[0]); findProcThrd.start(); findProcThrd.join(7000); if (!findProcThrd.bFoundIt && !findProcThrd.bStillRunning) { sRet = "Unable to start " + sArgs[0] + ""; } } catch (ActivityNotFoundException anf) { anf.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } ctx = null; return (sRet); }
From source file:com.mozilla.SUTAgentAndroid.service.DoCommand.java
public String StrtUpdtOMatic(String sPkgName, String sPkgFileName, String sCallBackIP, String sCallBackPort) { String sRet = ""; Context ctx = contextWrapper.getApplicationContext(); PackageManager pm = ctx.getPackageManager(); Intent prgIntent = new Intent(); prgIntent.setPackage("com.mozilla.watcher"); try {/*w ww .j a va2 s . c om*/ PackageInfo pi = pm.getPackageInfo("com.mozilla.watcher", PackageManager.GET_SERVICES | PackageManager.GET_INTENT_FILTERS); ServiceInfo[] si = pi.services; for (int i = 0; i < si.length; i++) { ServiceInfo s = si[i]; if (s.name.length() > 0) { prgIntent.setClassName(s.packageName, s.name); break; } } } catch (NameNotFoundException e) { e.printStackTrace(); sRet = sErrorPrefix + "watcher is not properly installed"; return (sRet); } prgIntent.putExtra("command", "updt"); prgIntent.putExtra("pkgName", sPkgName); prgIntent.putExtra("pkgFile", sPkgFileName); prgIntent.putExtra("reboot", true); try { if ((sCallBackIP != null) && (sCallBackPort != null) && (sCallBackIP.length() > 0) && (sCallBackPort.length() > 0)) { FileOutputStream fos = ctx.openFileOutput("update.info", Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE); String sBuffer = sCallBackIP + "," + sCallBackPort + "\rupdate started " + sPkgName + " " + sPkgFileName + "\r"; fos.write(sBuffer.getBytes()); fos.flush(); fos.close(); fos = null; prgIntent.putExtra("outFile", ctx.getFilesDir() + "/update.info"); } else { if (prgIntent.hasExtra("outFile")) { System.out.println("outFile extra unset from intent"); prgIntent.removeExtra("outFile"); } } ComponentName cn = contextWrapper.startService(prgIntent); if (cn != null) sRet = "exit"; else sRet = sErrorPrefix + "Unable to use watcher service"; } catch (ActivityNotFoundException anf) { sRet = sErrorPrefix + "Activity Not Found Exception [updt] call failed"; anf.printStackTrace(); } catch (FileNotFoundException e) { sRet = sErrorPrefix + "File creation error [updt] call failed"; e.printStackTrace(); } catch (IOException e) { sRet = sErrorPrefix + "File error [updt] call failed"; e.printStackTrace(); } ctx = null; return (sRet); }