List of usage examples for android.content Intent FLAG_ACTIVITY_NEW_TASK
int FLAG_ACTIVITY_NEW_TASK
To view the source code for android.content Intent FLAG_ACTIVITY_NEW_TASK.
Click Source Link
From source file:com.anykey.balala.activity.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addCategory(Intent.CATEGORY_HOME); startActivity(intent);//w w w .j a v a 2 s . com return true; } return super.onKeyDown(keyCode, event); }
From source file:com.appnexus.opensdk.ANJAMImplementation.java
private static void callDeepLink(WebView webView, Uri uri) { String cb = uri.getQueryParameter("cb"); String urlParam = uri.getQueryParameter("url"); LinkedList<BasicNameValuePair> list = new LinkedList<BasicNameValuePair>(); list.add(new BasicNameValuePair(KEY_CALLER, CALL_DEEPLINK)); if ((webView.getContext() == null) || (urlParam == null)) { loadResult(webView, cb, list);// ww w.ja v a 2 s . co m return; } try { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Uri.decode(urlParam))); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); webView.getContext().startActivity(intent); } catch (ActivityNotFoundException e) { loadResult(webView, cb, list); } }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.StatusObj.java
@Override public void activate(Context context, SignedObj obj) { //linkify should have picked it up already but if we are in TV mode we //still need to activate Intent intent = new Intent(Intent.ACTION_VIEW); String text = obj.getJson().optString(TEXT); //launch the first thing that looks like a link Matcher m = p.matcher(text);/*from ww w.ja va 2s. c o m*/ while (m.find()) { Uri uri = Uri.parse(m.group()); String scheme = uri.getScheme(); if (scheme != null && (scheme.equalsIgnoreCase("http") || scheme.equalsIgnoreCase("https"))) { intent.setData(uri); if (!(context instanceof Activity)) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } context.startActivity(intent); return; } } }
From source file:com.cbtec.eliademy.EliademyLms.java
/** * Executes the request.//from www . ja v a 2s .co m * * This method is called from the WebView thread. To do a non-trivial amount * of work, use: cordova.getThreadPool().execute(runnable); * * To run on the UI thread, use: * cordova.getActivity().runOnUiThread(runnable); * * @param action * The action to execute. * @param rawArgs * The exec() arguments in JSON form. * @param callbackContext * The callback context used when calling back into JavaScript. * @return Whether the action was valid. * @throws JSONException */ @Override public boolean execute(String action, JSONArray data, final CallbackContext callbackContext) throws JSONException { Log.i("HLMS", action); if ((action.compareTo("openfilesrv") == 0)) { try { Uri fileuri = Uri.parse(data.getString(0)); Intent intent = new Intent(Intent.ACTION_VIEW); String mimeextn = android.webkit.MimeTypeMap.getFileExtensionFromUrl(data.getString(0)); if (mimeextn.isEmpty()) { mimeextn = data.getString(0).substring(data.getString(0).indexOf(".") + 1); ; } String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(mimeextn); Log.i("HLMS", fileuri + " " + mimetype); intent.setDataAndType(fileuri, mimetype); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); cordova.getActivity().getApplicationContext().startActivity(intent); callbackContext.success(); } catch (Exception e) { Log.e("HLMS", "exception", e); callbackContext.error(0); } return true; } else if ((action.compareTo("getfilesrv") == 0)) { this.mCallbackContext = callbackContext; cordova.getThreadPool().execute(new Runnable() { @Override public void run() { try { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*");// TODO: Restrict file types cordova.startActivityForResult(EliademyLms.this, intent, submitFileCode); } catch (Exception e) { Log.e("HLMS", "exception", e); callbackContext.error(0); } return; } }); } else if ((action.compareTo("initservice") == 0)) { if (!mIsBound) { this.mCallbackContext = callbackContext; JSONObject tmp = new JSONObject(data.getString(0)); String sname = tmp.getString("servicename"); if (sname.contains("eliademy")) { mServiceName = "com.cbtec.serviceeliademy"; } else { // From url determine version 2.2, 2.3, 2.4 and change mServiceName = "com.cbtec.service" + sname; } Log.i("HLMS", "Connecting to service: " + mServiceName); doBindService(); } else { callbackContext.success(); } return true; } else { final String aAction = action; final JSONArray aData = data; String mappedCmd = null; try { mappedCmd = mapExecCommand(aData.getString(0)); } catch (JSONException e) { Log.e("HLMS", "exception", e); } if (mappedCmd == null) { Log.i("HLMS", "LMS service call failed " + mappedCmd); callbackContext.error(0);// TODO : error enum return false; } final String execCmd = mappedCmd; cordova.getThreadPool().execute(new Runnable() { @Override @SuppressLint("NewApi") public void run() { Log.i("HLMS", "Runner execute " + aAction + aData.toString()); if (aAction.compareTo("lmsservice") == 0) { try { String retval = null; Log.i("HLMS", "Execute cmd: " + execCmd); if (execCmd.compareTo("initialize") == 0) { if (mIBinder.initializeService(aData.getString(1))) { String token = mIBinder.eliademyGetWebServiceToken(); callbackContext.success(token); return; } } else if (execCmd.compareTo("deinitialize") == 0) { if (mIBinder.deInitializeService(aData.getString(1))) { doUnbindService(); callbackContext.success(); return; } } else if (execCmd.compareTo("pushregister") == 0) { Log.i("pushdata", aData.getString(1)); if (mIBinder.registerPushNotifications(aData.getString(1))) { callbackContext.success(); return; } } else if (execCmd.compareTo("pushunregister") == 0) { Log.i("pushdata", aData.getString(1)); if (mIBinder.unregisterPushNotifications(aData.getString(1))) { callbackContext.success(); return; } } else if (execCmd.compareTo("servicetoken") == 0) { retval = mIBinder.eliademyGetWebServiceToken(); } else if (execCmd.compareTo("siteinfo") == 0) { retval = mIBinder.eliademyGetSiteInformation(aData.getString(1)); } else if (execCmd.compareTo("get_user_courses") == 0) { retval = mIBinder.eliademyGetUsersCourses(aData.getString(1)); } else if (execCmd.compareTo("get_user_forums") == 0) { retval = mIBinder.eliademyGetUserForums(aData.getString(1)); } else if (execCmd.compareTo("get_user_info") == 0) { retval = mIBinder.eliademyGetUserInformation(aData.getString(1)); } else if (execCmd.compareTo("exec_webservice") == 0) { Log.i("HLMS", "Execute webservice"); retval = mIBinder.eliademyExecWebService(aData.getString(0), aData.getString(1)); } else if (execCmd.compareTo("course_get_contents") == 0) { retval = mIBinder.eliademyGetCourseContents(aData.getString(1)); } else if (execCmd.compareTo("course_get_enrolled_users") == 0) { retval = mIBinder.eliademyGetEnrolledUsers(aData.getString(1)); } else { Log.i("HLMS", "LMS service failed " + execCmd); callbackContext.error(0);// TODO : error enum } if (!retval.isEmpty()) { Log.i("HLMS", "LMS service call success"); callbackContext.success(retval); } else { Log.i("HLMS", "LMS service call failed"); callbackContext.error(0);// TODO : error enum } } catch (Exception e) { Log.e("HLMS", "exception", e); callbackContext.error(e.getMessage()); return; } } else { Log.i("LMS", "Unsupported action call !!"); callbackContext.error(0); return; } } }); } return true; }
From source file:eltharis.wsn.showAllActivity.java
/** * Called when the activity is first created. *///from w w w.ja v a2 s .c o m @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); try { String response = executeGET(); showAll(response); } catch (Exception e) { Toast toast = Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_LONG); //do debuggowania toast.show(); } adapter = new ArrayAdapter<User>(this, android.R.layout.simple_list_item_1, users); setListAdapter(adapter); ListView lv = getListView(); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { //nasuchiwanie, czy jaki z uytkownikw by nacinity public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = ((TextView) view).getText().toString(); Toast.makeText(getBaseContext(), username, Toast.LENGTH_SHORT).show(); User selected = null; for (User u : users) { if (u.getUsername().equals(username)) { selected = u; break; } } if (selected != null) { Intent intent = new Intent(getBaseContext(), showIDActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra("id", selected.getId()); //dodajemy jako Extra do intentu. S to tak jakby parametry getBaseContext().startActivity(intent); //zaczynamy intent } } }); }
From source file:com.gotraveling.insthub.BeeFramework.service.PushMessageReceiver.java
@Override public void onNotificationClicked(Context context, String title, String description, String customContentString) { String notifyString = " title=" + title + " description=" + description + " customContent=" + customContentString;/*from w ww . j a v a2 s . c o m*/ //System.out.println("notifyString:"+notifyString); Intent responseIntent = null; responseIntent = new Intent(EcmobileMainActivity.ACTION_PUSHCLICK); responseIntent.setClass(context, EcmobileMainActivity.class); responseIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (customContentString != null) { responseIntent.putExtra(EcmobileMainActivity.CUSTOM_CONTENT, customContentString); } context.startActivity(responseIntent); }
From source file:com.kogitune.wearlocationwatchface.WatchFaceService.java
public void startRefresh() { floatingActionBarManager.startRefresh(); GoogleApiClientObservable.connection(this).flatMap(GoogleApiClientObservable::location).map(location -> { int range = new WearSharedPreference(this).get(getString(R.string.key_preference_search_range), getResources().getInteger(R.integer.search_range_default)); return "https://api.flickr.com/services/rest/?method=flickr.photos.search&group_id=1463451@N25&api_key=" + BuildConfig.FLICKR_API_KEY + "&license=1%2C2%2C3%2C4%2C5%2C6&lat=" + location.getLatitude() + "&lon=" + location.getLongitude() + "&radius=" + range + "&extras=url_n,url_l&per_page=30&format=json&nojsoncallback=1"; }).flatMap(url -> GoogleApiClientObservable.fetchText(this, url)).timeout(50, TimeUnit.SECONDS) .observeOn(mainThread()).subscribeOn(Schedulers.io()).subscribe(this::applyView, e -> { if (e instanceof LocationNotAvailableException) { try { final Intent intent = new Intent("android.settings.LOCATION_SOURCE_SETTINGS"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); return; } catch (final ActivityNotFoundException e1) { }/*from w ww .j a v a 2s . c o m*/ } floatingActionBarManager.stopRefresh(); Toast.makeText(WatchFaceService.this, "Can't get photo in time.", Toast.LENGTH_SHORT); e.printStackTrace(); }); }
From source file:com.hybris.mobile.activity.BarCodeScannerActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { String contents = data.getStringExtra(SCAN_RESULT); String format = data.getStringExtra(SCAN_RESULT_FORMAT); Log.i(TAG, "Contents: " + contents); Log.i(TAG, "format: " + format); String isUseSpecificBaseUrl = Hybris .getSharedPreferenceString(InternalConstants.KEY_PREF_TOGGLE_SPECIFIC_BASE_URL); if (StringUtils.equals(isUseSpecificBaseUrl, String.valueOf(false))) { Log.i(TAG, "calling default handler for url: " + contents); // We run the task to check the format and data availability of the barcode scanned new CheckBarcodeFormatAndValueTask().execute(contents, format); } else {//from w w w. j a va 2s . c o m //isScannerRunning = false; // WebView myWebView = new WebView(this); // myWebView = (WebView) findViewById(R.layout.app_web_view); Log.i(TAG, "calling webview activity with url: " + contents); // myWebView.loadUrl(contents); // WebSettings webSettings = myWebView.getSettings(); // webSettings.setJavaScriptEnabled(true); Intent localintent = new Intent(Hybris.getAppContext(), ScanCodeWebViewActivity.class); localintent.putExtra(Constants.DATA, contents); localintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Log.i(TAG, "Sending intent to start webview for url"); Hybris.getAppContext().startActivity(localintent); } } else if (resultCode == RESULT_CANCELED) { Message msg = new Message(); msg.what = BarCodeScannerActivity.MSG_CANCEL_SCAN; mHandler.sendMessage(msg); } }
From source file:de.micmun.android.workdaystarget.DaysLeftService.java
/** * Updates the days to target./*from w w w . j a v a 2 s . com*/ */ private void updateDays() { AppWidgetManager appManager = AppWidgetManager.getInstance(this); ComponentName cName = new ComponentName(getApplicationContext(), DaysLeftProvider.class); int[] appIds = appManager.getAppWidgetIds(cName); DayCalculator dayCalc = new DayCalculator(); if (!isOnline()) { try { Thread.sleep(60000); } catch (InterruptedException e) { Log.e(TAG, "Interrupted: " + e.getLocalizedMessage()); } } for (int appId : appIds) { PrefManager pm = new PrefManager(this, appId); Calendar target = pm.getTarget(); boolean[] chkDays = pm.getCheckedDays(); int days = pm.getLastDiff(); if (isOnline()) { try { days = dayCalc.getDaysLeft(target.getTime(), chkDays); Map<String, Object> saveMap = new HashMap<String, Object>(); Long diff = Long.valueOf(days); saveMap.put(PrefManager.KEY_DIFF, diff); pm.save(saveMap); } catch (JSONException e) { Log.e(TAG, "ERROR holidays: " + e.getLocalizedMessage()); } } else { Log.e(TAG, "No internet connection!"); } RemoteViews rv = new RemoteViews(this.getPackageName(), R.layout.appwidget_layout); DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT); String targetStr = df.format(target.getTime()); rv.setTextViewText(R.id.target, targetStr); String dayStr = String.format(Locale.getDefault(), "%d %s", days, getResources().getString(R.string.unit)); rv.setTextViewText(R.id.dayCount, dayStr); // put widget id into intent Intent configIntent = new Intent(this, ConfigActivity.class); configIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); configIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); configIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appId); configIntent.setData(Uri.parse(configIntent.toUri(Intent.URI_INTENT_SCHEME))); PendingIntent pendIntent = PendingIntent.getActivity(this, 0, configIntent, PendingIntent.FLAG_UPDATE_CURRENT); rv.setOnClickPendingIntent(R.id.widgetLayout, pendIntent); // update widget appManager.updateAppWidget(appId, rv); } }