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.jaspersoft.android.jaspermobile.test.acceptance.favorites.FavoritesPageTest.java
public void testAddToFavoriteFromReportView() { FakeHttpLayerManager.addHttpResponseRule(ApiMatcher.RESOURCES, TestResponses.ONLY_REPORT); startActivityUnderTest();/* ww w. jav a2 s. co m*/ // Force only reports Intent intent = LibraryActivity_.intent(mApplication).flags(Intent.FLAG_ACTIVITY_NEW_TASK).get(); getInstrumentation().startActivitySync(intent); getInstrumentation().waitForIdleSync(); // Select report FakeHttpLayerManager.setDefaultHttpResponse(TestResponses.get().noContent()); onData(is(instanceOf(ResourceLookup.class))).inAdapterView(withId(android.R.id.list)).atPosition(0) .perform(click()); // Add to favorite onView(withId(R.id.favoriteAction)).perform(click()); pressBack(); pressBack(); onData(is(instanceOf(Cursor.class))).inAdapterView(withId(android.R.id.list)).atPosition(0) .perform(click()); // Remove from favorite onView(withId(R.id.favoriteAction)).perform(click()); pressBack(); onView(withId(android.R.id.list)).check(hasTotalCount(0)); onView(withId(android.R.id.empty)) .check(matches(allOf(withText(R.string.f_empty_list_msg), isDisplayed()))); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.PictureObj.java
@Override public void activate(Context context, SignedObj obj) { // TODO: set data uri for obj Intent intent = new Intent(context, ImageGalleryActivity.class); intent.setData(Feed.uriForName(obj.getFeedName())); intent.putExtra("objHash", obj.getHash()); if (!(context instanceof Activity)) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); }/*from ww w .ja v a 2s. c o m*/ context.startActivity(intent); }
From source file:org.zywx.wbpalmstar.engine.EDownloadDialog.java
private void downloadDone() { stopDownload();//from w w w .j a v a 2 s . c o m Intent installIntent = new Intent(Intent.ACTION_VIEW); String filename = mTmpFile.getAbsolutePath(); Uri path = Uri.parse(filename); if (path.getScheme() == null) { path = Uri.fromFile(new File(filename)); } installIntent.setDataAndType(path, mimetype); installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { getContext().startActivity(installIntent); } catch (Exception e) { e.printStackTrace(); mProgressHandler.sendMessage(mProgressHandler.obtainMessage(-2, "?")); } }
From source file:com.google.wireless.speed.speedometer.AccountSelector.java
private void getAuthToken(AccountManagerFuture<Bundle> result) { Log.i(SpeedometerApp.TAG, "getAuthToken() called, result " + result); String errMsg = "Failed to get login cookie. "; Bundle bundle;/*from w ww . j a v a 2 s.c o m*/ try { bundle = result.getResult(); Intent intent = (Intent) bundle.get(AccountManager.KEY_INTENT); if (intent != null) { // User input required. (A UI will pop up for user's consent to allow // this app access account information.) Log.i(SpeedometerApp.TAG, "Starting account manager activity"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } else { Log.i(SpeedometerApp.TAG, "Executing getCookie task"); synchronized (this) { this.authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN); this.checkinFuture = checkinExecutor.submit(new GetCookieTask()); } } } catch (OperationCanceledException e) { Log.e(SpeedometerApp.TAG, errMsg, e); throw new RuntimeException("Can't get login cookie", e); } catch (AuthenticatorException e) { Log.e(SpeedometerApp.TAG, errMsg, e); throw new RuntimeException("Can't get login cookie", e); } catch (IOException e) { Log.e(SpeedometerApp.TAG, errMsg, e); throw new RuntimeException("Can't get login cookie", e); } }
From source file:in.codehex.facilis.LoginActivity.java
/** * Send request to the server to process login and fetch user token. * * @param email email address of the user. * @param pass password submitted by the user. * @param client wifi mac address of the user's device */// w w w. j av a 2 s .co m private void processLogin(final String email, final String pass, final String client) { JSONObject jsonObject = new JSONObject(); try { jsonObject.put(Config.KEY_API_USERNAME, email); jsonObject.put(Config.KEY_API_PASSWORD, pass); jsonObject.put(Config.KEY_API_CLIENT, client); } catch (JSONException e) { // TODO: remove toast Toast.makeText(LoginActivity.this, "Error occurred while generating data - " + e.getMessage(), Toast.LENGTH_SHORT).show(); } showProgressDialog(); JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, Config.API_LOGIN, jsonObject, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { hideProgressDialog(); try { String firstName = response.getString(Config.KEY_API_FIRST_NAME); String lastName = response.getString(Config.KEY_API_LAST_NAME); int userId = response.getInt(Config.KEY_API_USER_ID); int companyId = response.getInt(Config.KEY_PREF_COMPANY_ID); boolean creditStatus = response.getBoolean(Config.KEY_PREF_CREDIT_STATUS); int role = response.getInt(Config.KEY_API_ROLE); String token = response.getString(Config.KEY_API_TOKEN); String userImage = response.getString(Config.KEY_API_USER_IMAGE); SharedPreferences.Editor editor = userPreferences.edit(); editor.putString(Config.KEY_PREF_FIRST_NAME, firstName); editor.putString(Config.KEY_PREF_LAST_NAME, lastName); editor.putInt(Config.KEY_PREF_USER_ID, userId); editor.putInt(Config.KEY_PREF_COMPANY_ID, companyId); editor.putBoolean(Config.KEY_PREF_CREDIT_STATUS, creditStatus); editor.putInt(Config.KEY_PREF_ROLE, role); editor.putString(Config.KEY_PREF_TOKEN, token); editor.putString(Config.KEY_USER_IMAGE, userImage); editor.apply(); mIntent = new Intent(LoginActivity.this, MainActivity.class); mIntent.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(mIntent); } catch (JSONException e) { // TODO: remove toast Toast.makeText(LoginActivity.this, "Error occurred while parsing data - " + e.getMessage(), Toast.LENGTH_SHORT) .show(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { hideProgressDialog(); NetworkResponse response = error.networkResponse; try { byte[] data = response.data; String mError = new String(data); JSONObject errorObject = new JSONObject(mError); JSONArray nonFieldErrors = errorObject.getJSONArray(Config.KEY_API_NON_FIELD_ERRORS); String errorData = nonFieldErrors.getString(0); Toast.makeText(LoginActivity.this, errorData, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { // TODO: remove toast Toast.makeText(LoginActivity.this, "Error occurred while parsing data - " + e.getMessage(), Toast.LENGTH_SHORT) .show(); } catch (NullPointerException e) { // TODO: remove toast Toast.makeText(LoginActivity.this, "Network error - " + e.getMessage(), Toast.LENGTH_SHORT).show(); } } }); AppController.getInstance().addToRequestQueue(jsonObjectRequest, "login"); }
From source file:samples.piggate.com.piggateCompleteExample.Activity_SingUp.java
public void backButton() { Intent slideactivity = new Intent(Activity_SingUp.this, Activity_Main.class); slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); Bundle bndlanimation = ActivityOptions .makeCustomAnimation(getApplicationContext(), R.anim.slidefromleft, R.anim.slidetoright).toBundle(); startActivity(slideactivity, bndlanimation); }
From source file:org.tomahawk.tomahawk_android.utils.TomahawkExceptionReporter.java
/** * Pull information from the given {@link CrashReportData} and send it via HTTP to * oops.tomahawk-player.org or sends it as a TEXT intent, if IS_SILENT is true *///from www . ja v a 2 s . c om @Override public void send(CrashReportData data) throws ReportSenderException { StringBuilder body = new StringBuilder(); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("Version", data.getProperty(ReportField.APP_VERSION_NAME))); nameValuePairs.add(new BasicNameValuePair("BuildID", data.getProperty(ReportField.BUILD))); nameValuePairs.add(new BasicNameValuePair("ProductName", "tomahawk-android")); nameValuePairs.add(new BasicNameValuePair("Vendor", "Tomahawk")); nameValuePairs.add(new BasicNameValuePair("timestamp", data.getProperty(ReportField.USER_CRASH_DATE))); for (NameValuePair pair : nameValuePairs) { body.append("--thkboundary\r\n"); body.append("Content-Disposition: form-data; name=\""); body.append(pair.getName()).append("\"\r\n\r\n").append(pair.getValue()).append("\r\n"); } body.append("--thkboundary\r\n"); body.append("Content-Disposition: form-data; name=\"upload_file_minidump\"; filename=\"") .append(data.getProperty(ReportField.REPORT_ID)).append("\"\r\n"); body.append("Content-Type: application/octet-stream\r\n\r\n"); body.append("============== Tomahawk Exception Report ==============\r\n\r\n"); body.append("Report ID: ").append(data.getProperty(ReportField.REPORT_ID)).append("\r\n"); body.append("App Start Date: ").append(data.getProperty(ReportField.USER_APP_START_DATE)).append("\r\n"); body.append("Crash Date: ").append(data.getProperty(ReportField.USER_CRASH_DATE)).append("\r\n\r\n"); body.append("--------- Phone Details ----------\r\n"); body.append("Phone Model: ").append(data.getProperty(ReportField.PHONE_MODEL)).append("\r\n"); body.append("Brand: ").append(data.getProperty(ReportField.BRAND)).append("\r\n"); body.append("Product: ").append(data.getProperty(ReportField.PRODUCT)).append("\r\n"); body.append("Display: ").append(data.getProperty(ReportField.DISPLAY)).append("\r\n"); body.append("-----------------------------------\r\n\r\n"); body.append("----------- Stack Trace -----------\r\n"); body.append(data.getProperty(ReportField.STACK_TRACE)).append("\r\n"); body.append("-----------------------------------\r\n\r\n"); body.append("------- Operating System ---------\r\n"); body.append("App Version Name: ").append(data.getProperty(ReportField.APP_VERSION_NAME)).append("\r\n"); body.append("Total Mem Size: ").append(data.getProperty(ReportField.TOTAL_MEM_SIZE)).append("\r\n"); body.append("Available Mem Size: ").append(data.getProperty(ReportField.AVAILABLE_MEM_SIZE)).append("\r\n"); body.append("Dumpsys Meminfo: ").append(data.getProperty(ReportField.DUMPSYS_MEMINFO)).append("\r\n"); body.append("-----------------------------------\r\n\r\n"); body.append("-------------- Misc ---------------\r\n"); body.append("Package Name: ").append(data.getProperty(ReportField.PACKAGE_NAME)).append("\r\n"); body.append("File Path: ").append(data.getProperty(ReportField.FILE_PATH)).append("\r\n"); body.append("Android Version: ").append(data.getProperty(ReportField.ANDROID_VERSION)).append("\r\n"); body.append("Build: ").append(data.getProperty(ReportField.BUILD)).append("\r\n"); body.append("Initial Configuration: ").append(data.getProperty(ReportField.INITIAL_CONFIGURATION)) .append("\r\n"); body.append("Crash Configuration: ").append(data.getProperty(ReportField.CRASH_CONFIGURATION)) .append("\r\n"); body.append("Settings Secure: ").append(data.getProperty(ReportField.SETTINGS_SECURE)).append("\r\n"); body.append("User Email: ").append(data.getProperty(ReportField.USER_EMAIL)).append("\r\n"); body.append("User Comment: ").append(data.getProperty(ReportField.USER_COMMENT)).append("\r\n"); body.append("-----------------------------------\r\n\r\n"); body.append("---------------- Logs -------------\r\n"); body.append("Logcat: ").append(data.getProperty(ReportField.LOGCAT)).append("\r\n\r\n"); body.append("Events Log: ").append(data.getProperty(ReportField.EVENTSLOG)).append("\r\n\r\n"); body.append("Radio Log: ").append(data.getProperty(ReportField.RADIOLOG)).append("\r\n"); body.append("-----------------------------------\r\n\r\n"); body.append("=======================================================\r\n\r\n"); body.append("--thkboundary\r\n"); body.append( "Content-Disposition: form-data; name=\"upload_file_tomahawklog\"; filename=\"Tomahawk.log\"\r\n"); body.append("Content-Type: text/plain\r\n\r\n"); body.append(data.getProperty(ReportField.LOGCAT)); body.append("\r\n--thkboundary--\r\n"); if ("true".equals(data.getProperty(ReportField.IS_SILENT))) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); body.insert(0, "Please tell us why you're sending us this log:\n\n\n\n\n"); intent.putExtra(Intent.EXTRA_TEXT, body.toString()); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "support@tomahawk-player.org" }); intent.putExtra(Intent.EXTRA_SUBJECT, "Tomahawk Android Log"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); TomahawkApp.getContext().startActivity(intent); } else { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://oops.tomahawk-player.org/addreport.php"); httppost.setHeader("Content-type", "multipart/form-data; boundary=thkboundary"); try { httppost.setEntity(new StringEntity(body.toString())); httpclient.execute(httppost); } catch (ClientProtocolException e) { Log.e(TAG, "send: " + e.getClass() + ": " + e.getLocalizedMessage()); } catch (IOException e) { Log.e(TAG, "send: " + e.getClass() + ": " + e.getLocalizedMessage()); } } }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.VideoObj.java
private void startViewer(Context context, Uri contentUri) { Log.d(TAG, "Launching viewer for " + contentUri); Intent i = new Intent(Intent.ACTION_VIEW); if (!(context instanceof Activity)) { i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); }/* w w w .j av a 2s. c om*/ i.setDataAndType(contentUri, "video/*"); context.startActivity(i); }
From source file:in.neoandroid.neoupdate.neoUpdate.java
private void startUpdateApk(Uri installerUri) { MimeTypeMap myMime = MimeTypeMap.getSingleton(); String mimeType = myMime.getMimeTypeFromExtension("apk"); Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(installerUri, mimeType);//"application/vnd.android.package-archive"); context.startActivity(intent);//from w w w. j av a 2 s . com }
From source file:com.phonegap.plugins.nativesettings.NativeSettings.java
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { PluginResult.Status status = PluginResult.Status.OK; Uri packageUri = Uri.parse("package:" + this.cordova.getActivity().getPackageName()); String result = ""; //Information on settings can be found here: //http://developer.android.com/reference/android/provider/Settings.html action = args.getString(0);/*from w w w . j ava2 s. c o m*/ Intent intent = null; if (action.equals("accessibility")) { intent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS); } else if (action.equals("account")) { intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT); } else if (action.equals("airplane_mode")) { intent = new Intent(android.provider.Settings.ACTION_AIRPLANE_MODE_SETTINGS); } else if (action.equals("apn")) { intent = new Intent(android.provider.Settings.ACTION_APN_SETTINGS); } else if (action.equals("application_details")) { intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packageUri); } else if (action.equals("application_development")) { intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS); } else if (action.equals("application")) { intent = new Intent(android.provider.Settings.ACTION_APPLICATION_SETTINGS); } //else if (action.equals("battery_saver")) { // intent = new Intent(android.provider.Settings.ACTION_BATTERY_SAVER_SETTINGS); //} else if (action.equals("bluetooth")) { intent = new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS); } else if (action.equals("captioning")) { intent = new Intent(android.provider.Settings.ACTION_CAPTIONING_SETTINGS); } else if (action.equals("cast")) { intent = new Intent(android.provider.Settings.ACTION_CAST_SETTINGS); } else if (action.equals("data_roaming")) { intent = new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS); } else if (action.equals("date")) { intent = new Intent(android.provider.Settings.ACTION_DATE_SETTINGS); } else if (action.equals("about")) { intent = new Intent(android.provider.Settings.ACTION_DEVICE_INFO_SETTINGS); } else if (action.equals("display")) { intent = new Intent(android.provider.Settings.ACTION_DISPLAY_SETTINGS); } else if (action.equals("dream")) { intent = new Intent(android.provider.Settings.ACTION_DREAM_SETTINGS); } else if (action.equals("home")) { intent = new Intent(android.provider.Settings.ACTION_HOME_SETTINGS); } else if (action.equals("keyboard")) { intent = new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS); } else if (action.equals("keyboard_subtype")) { intent = new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS); } else if (action.equals("storage")) { intent = new Intent(android.provider.Settings.ACTION_INTERNAL_STORAGE_SETTINGS); } else if (action.equals("locale")) { intent = new Intent(android.provider.Settings.ACTION_LOCALE_SETTINGS); } else if (action.equals("location")) { intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); } else if (action.equals("manage_all_applications")) { intent = new Intent(android.provider.Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS); } else if (action.equals("manage_applications")) { intent = new Intent(android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS); } else if (action.equals("memory_card")) { intent = new Intent(android.provider.Settings.ACTION_MEMORY_CARD_SETTINGS); } else if (action.equals("network")) { intent = new Intent(android.provider.Settings.ACTION_NETWORK_OPERATOR_SETTINGS); } else if (action.equals("nfcsharing")) { intent = new Intent(android.provider.Settings.ACTION_NFCSHARING_SETTINGS); } else if (action.equals("nfc_payment")) { intent = new Intent(android.provider.Settings.ACTION_NFC_PAYMENT_SETTINGS); } else if (action.equals("nfc_settings")) { intent = new Intent(android.provider.Settings.ACTION_NFC_SETTINGS); } //else if (action.equals("notification_listner")) { // intent = new Intent(android.provider.Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS); //} else if (action.equals("print")) { intent = new Intent(android.provider.Settings.ACTION_PRINT_SETTINGS); } else if (action.equals("privacy")) { intent = new Intent(android.provider.Settings.ACTION_PRIVACY_SETTINGS); } else if (action.equals("quick_launch")) { intent = new Intent(android.provider.Settings.ACTION_QUICK_LAUNCH_SETTINGS); } else if (action.equals("search")) { intent = new Intent(android.provider.Settings.ACTION_SEARCH_SETTINGS); } else if (action.equals("security")) { intent = new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS); } else if (action.equals("settings")) { intent = new Intent(android.provider.Settings.ACTION_SETTINGS); } else if (action.equals("show_regulatory_info")) { intent = new Intent(android.provider.Settings.ACTION_SHOW_REGULATORY_INFO); } else if (action.equals("sound")) { intent = new Intent(android.provider.Settings.ACTION_SOUND_SETTINGS); } else if (action.equals("store")) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + this.cordova.getActivity().getPackageName())); } else if (action.equals("sync")) { intent = new Intent(android.provider.Settings.ACTION_SYNC_SETTINGS); } else if (action.equals("usage")) { intent = new Intent(android.provider.Settings.ACTION_USAGE_ACCESS_SETTINGS); } else if (action.equals("user_dictionary")) { intent = new Intent(android.provider.Settings.ACTION_USER_DICTIONARY_SETTINGS); } else if (action.equals("voice_input")) { intent = new Intent(android.provider.Settings.ACTION_VOICE_INPUT_SETTINGS); } else if (action.equals("wifi_ip")) { intent = new Intent(android.provider.Settings.ACTION_WIFI_IP_SETTINGS); } else if (action.equals("wifi")) { intent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS); } else if (action.equals("wireless")) { intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS); } else { status = PluginResult.Status.INVALID_ACTION; callbackContext.sendPluginResult(new PluginResult(status, result)); return false; } if (args.length() > 1 && args.getBoolean(1)) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } this.cordova.getActivity().startActivity(intent); callbackContext.sendPluginResult(new PluginResult(status, result)); return true; }