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.avanade.C2DMReceiver.java
@Override public void onUnregistered(Context context) { Log.w("C2DMReceiver-onUnregistered", "got here!"); // String urlString = getResources().getString( // R.string.WhatsNewAtDataServiceUnRegisterURL); String urlString = "https://mobileapi.whatsnewat.com/WNADataService.svc/UnRegisterAndroid?deviceID='" + LoginScreen.androidDevice_id + "'"; HttpGet httpGet = new HttpGet(urlString); LoginScreen.httpFlag = 1;//www .j a v a2 s. c o m HttpGetRequest token = new HttpGetRequest(); httpGet.setHeader(Constants.emailId, LoginScreen.statEmailId); httpGet.setHeader(Constants.companyKey, LoginScreen.statCompKey); // obtain response XML from the server String xml = token.performGetRequest(httpGet); Intent dBUpdateIntent = new Intent(getBaseContext(), DatabaseUpdate.class); dBUpdateIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); dBUpdateIntent.putExtra("unregister", true); getApplication().startActivity(dBUpdateIntent); }
From source file:com.timrae.rikaidroid.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mWebView = (WebView) findViewById(R.id.webview); mWebClient = new WebViewClient() { @Override// w ww . j av a 2 s. co m public boolean shouldOverrideUrlLoading(WebView view, String url) { Uri uri = Uri.parse(url); if (uri.getScheme().equals("lookup")) { String query = uri.getHost(); Intent i = new Intent(AEDICT_INTENT); i.putExtra("kanjis", query); i.putExtra("showEntryDetailOnSingleResult", true); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); view.reload(); return true; } else { view.loadUrl(url); } return true; } }; mWebView.setWebViewClient(mWebClient); mEditText = (EditText) findViewById(R.id.search_src_text); mProgressBar = (ProgressBar) findViewById(R.id.progress_bar); if (mProgressBar != null) { mProgressBar.setVisibility(View.VISIBLE); } }
From source file:samples.piggate.com.piggateInfoDemo.InfoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_artwork); //Set action bar fields getSupportActionBar().setTitle(PiggateUser.getEmail()); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); title = (TextView) findViewById(R.id.InfoTitle); description = (TextView) findViewById(R.id.InfoDescription); image = (SmartImageView) findViewById(R.id.InfoImage); videoButton = (FloatingActionButton) findViewById(R.id.videoButton); errorDialog = new AlertDialog.Builder(this).create(); errorDialog.setTitle("Logout error"); errorDialog.setMessage("There is an error with the logout"); errorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { @Override//from w w w . j ava2 s. co m public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); networkErrorDialog = new AlertDialog.Builder(this).create(); networkErrorDialog.setTitle("Network error"); networkErrorDialog.setMessage("There is an error with the network connection"); networkErrorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); title.setText(getIntent().getExtras().getString("infoTitle")); description.setText(getIntent().getExtras().getString("infoDescription")); image.setImageUrl(getIntent().getExtras().getString("infoImageURL")); videoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (checkInternetConnection() == true) { //If internet is working //Start the video here Intent slideactivity = new Intent(getApplicationContext(), VideoViewActivity.class); slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); //Information about selected content slideactivity.putExtra("infoTitle", getIntent().getExtras().getString("infoTitle")); slideactivity.putExtra("infoDescription", getIntent().getExtras().getString("infoDescription")); slideactivity.putExtra("infoImageURL", getIntent().getExtras().getString("infoImageURL")); slideactivity.putExtra("infoVideoURL", getIntent().getExtras().getString("infoVideoURL")); Bundle bndlanimation = ActivityOptions .makeCustomAnimation(getApplicationContext(), R.anim.slidefromright, R.anim.slidetoleft) .toBundle(); getApplicationContext().startActivity(slideactivity, bndlanimation); } else { //If internet conexion is not working displays an error message networkErrorDialog.show(); } } }); }
From source file:co.uk.gauntface.cordova.plugin.gcmbrowserlaunch.PushNotificationReceiver.java
private void launchBrowserTask(Context context, String url, String packageName) { Log.v(C.TAG, "launchBrowserTask"); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); browserIntent.setPackage(packageName); browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); List<ResolveInfo> activitiesList = context.getPackageManager().queryIntentActivities(browserIntent, -1); if (activitiesList.size() > 0) { browserIntent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); context.startActivity(browserIntent); } else {//from w ww. j av a2 s . c om Intent playStoreIntent = new Intent(Intent.ACTION_VIEW); playStoreIntent.setData(Uri.parse("market://details?id=" + packageName)); playStoreIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(playStoreIntent); /**Intent rawIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); rawIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(rawIntent);**/ } }
From source file:fr.itinerennes.ItineRennesApplication.java
/** * Inits ACRA and strict mode./* w w w .ja va 2 s .c o m*/ * * @see android.app.Application#onCreate() */ @Override public final void onCreate() { if (Conf.ACRA_ENABLED) { // The following line triggers the initialization of ACRA ACRA.init(this); } setupStrictMode(); final Intent i = new Intent(this, LoadingActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); startActivity(i); super.onCreate(); }
From source file:prince.app.ccm.Fragment_Log.java
private void setUpListener() { AsyncSession.setCallback(new AsyncCallback() { @Override//from w w w . j a v a2 s . c o m public void onPostExecute(boolean result) { if (result) { saveCredentials(); Tool.getInstance().modBolPref(Util.SIGN_IN, true); Intent intent = new Intent(getActivity(), Activity_Main.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } else { if (!Tool.getInstance().isConnection()) { Toast.makeText(getActivity(), getResources().getString(R.string.no_connection), Toast.LENGTH_LONG).show(); } else { Toast.makeText(getActivity(), getResources().getString(R.string.user_passwd_error), Toast.LENGTH_LONG).show(); } onCancel(); } } @Override public void onCancel() { mAuthTask = null; showProgress(false); } }); }
From source file:com.frostwire.android.gui.util.UIUtils.java
public static void sendShutdownIntent(Context ctx) { Intent i = new Intent(ctx, MainActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); i.putExtra("shutdown-frostwire", true); ctx.startActivity(i);// w w w .j av a 2 s . c o m }
From source file:com.memetro.android.oauth.OAuth.java
public JSONObject call(String controller, String action, Map<String, String> params) { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(oauthServer + controller + "/" + action); try {//ww w . j a v a 2 s .c o m // Add data httppost.setEntity(new UrlEncodedFormEntity(Map2NameValuePair(params))); // Execute Post HttpResponse response = httpclient.execute(httppost); // Catch headers int statusCode = response.getStatusLine().getStatusCode(); lastHttpStatus = statusCode; if (statusCode != 200) { JSONObject returnJ = new JSONObject(); returnJ.put("success", false); returnJ.put("data", new JSONArray()); Log.d("Http Status Code", String.valueOf(statusCode)); switch (statusCode) { case 401: if (refreshToken() && firstAuthCall) { firstAuthCall = false; Utils utils = new Utils(); params.put("access_token", utils.getToken(context)); return call(controller, action, params); } returnJ.put("message", context.getString(R.string.session_expired)); Utils utils = new Utils(); utils.setToken(context, "", ""); Intent intent = new Intent(context, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); return returnJ; case 404: returnJ.put("message", context.getString(R.string.action_not_found)); return returnJ; case 500: returnJ.put("message", context.getString(R.string.server_error)); return returnJ; default: returnJ.put("message", context.getString(R.string.internal_error)); return returnJ; } } BufferedReader reader = new BufferedReader( new InputStreamReader(response.getEntity().getContent(), "UTF-8")); String json = reader.readLine(); JSONTokener tokener = new JSONTokener(json); return new JSONObject(tokener); } catch (ClientProtocolException e) { // TODO Auto-generated catch block } catch (JSONException e) { // TODO Auto-generated catch block } catch (IOException e) { // TODO Auto-generated catch block } return new JSONObject(); }
From source file:id.zelory.tanipedia.activity.KomoditasActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_komoditas); toolbar = (Toolbar) findViewById(R.id.anim_toolbar); setSupportActionBar(toolbar);/*from w w w. j av a2 s . c om*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbar.setTitle("Harga Komoditas"); animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow); drawerLayout = (DrawerLayout) findViewById(R.id.nav_drawer); setUpNavDrawer(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.getMenu().getItem(3).setChecked(true); TextView nama = (TextView) navigationView.findViewById(R.id.nama); nama.setText(PrefUtils.ambilString(this, "nama")); TextView email = (TextView) navigationView.findViewById(R.id.email); email.setText(PrefUtils.ambilString(this, "email")); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(true); drawerLayout.closeDrawers(); Intent intent; switch (menuItem.getItemId()) { case R.id.cuaca: intent = new Intent(KomoditasActivity.this, CuacaActivity.class); break; case R.id.berita: intent = new Intent(KomoditasActivity.this, BeritaActivity.class); break; case R.id.tanya: intent = new Intent(KomoditasActivity.this, TanyaActivity.class); break; case R.id.harga: return true; case R.id.logout: PrefUtils.simpanString(KomoditasActivity.this, "nama", null); intent = new Intent(KomoditasActivity.this, LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); return true; case R.id.tentang: intent = new Intent(KomoditasActivity.this, TentangActivity.class); startActivity(intent); return true; default: return true; } startActivity(intent); finish(); return true; } }); recyclerView = (RecyclerView) findViewById(R.id.scrollableview); recyclerView.setHasFixedSize(true); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(linearLayoutManager); imageHeader = (ImageView) findViewById(R.id.header); imageHeader.setVisibility(View.GONE); fabButton = (FabButton) findViewById(R.id.determinate); fabButton.showProgress(true); new DownloadData().execute(); fabButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { fabButton.showProgress(true); new DownloadData().execute(); } }); }
From source file:fib.lcfib.raco.Controladors.ControladorLoginRaco.java
private void showAddDialog() { loginDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND); loginDialog.setTitle(R.string.loginRaco); LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View dialogView = li.inflate(R.layout.contingut_login, null); loginDialog.setContentView(dialogView); username = (EditText) dialogView.findViewById(R.id.login); password = (EditText) dialogView.findViewById(R.id.password); Button okButton = (Button) dialogView.findViewById(R.id.acceptar_button); Button cancelButton = (Button) dialogView.findViewById(R.id.cancel_button); loginDialog.setCancelable(false);//from ww w . jav a2 s. c o m loginDialog.show(); okButton.setOnClickListener(new OnClickListener() { // @Override public void onClick(View v) { try { String usernameAux = username.getText().toString().trim(); String passwordAux = password.getText().toString().trim(); usernameAux = URLEncoder.encode(usernameAux, "UTF-8"); passwordAux = URLEncoder.encode(passwordAux, "UTF-8"); boolean correcte = check_user(usernameAux, passwordAux); if (correcte) { Toast.makeText(getApplicationContext(), R.string.login_correcte, Toast.LENGTH_LONG).show(); } else { Toast.makeText(getApplicationContext(), R.string.errorLogin, Toast.LENGTH_LONG).show(); } if ("zonaRaco".equals(queEs)) { Intent intent = new Intent(ControladorLoginRaco.this, ControladorTabIniApp.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("esLogin", "zonaRaco"); startActivity(intent); } else { Intent act = new Intent(ControladorLoginRaco.this, ControladorTabIniApp.class); // Aquestes 2 lnies provoquen una excepci per no peta // simplement informa s normal act.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); act.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(act); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } private boolean check_user(String username, String password) { GestorCertificats.allowAllSSL(); AndroidUtils au = AndroidUtils.getInstance(); /** open connection */ //Aix tanquem les connexions segur System.setProperty("http.keepAlive", "false"); try { InputStream is = null; HttpGet request = new HttpGet(au.URL_LOGIN + "username=" + username + "&password=" + password); HttpClient client = new DefaultHttpClient(); HttpResponse response = client.execute(request); final int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { Header[] headers = response.getHeaders("Location"); if (headers != null && headers.length != 0) { String newUrl = headers[headers.length - 1].getValue(); request = new HttpGet(newUrl); client.execute(request); } } /** Get Keys */ is = response.getEntity().getContent(); ObjectMapper m = new ObjectMapper(); JsonNode rootNode = m.readValue(is, JsonNode.class); is.close(); client.getConnectionManager().closeExpiredConnections(); if (rootNode.isNull()) { return false; } else { // GenerarUrl(); /** calendari ics */ String KEYportadaCal = rootNode.path("/ical/portada.ics").getTextValue().toString(); /** calendari rss */ String KEYportadaRss = rootNode.path("/ical/portada.rss").getTextValue().toString(); /** Avisos */ String KEYavisos = rootNode.path("/extern/rss_avisos.jsp").getTextValue().toString(); /** Assigraco */ String KEYAssigRaco = rootNode.path("/api/assigList").getTextValue().toString(); /** Horari */ String KEYIcalHorari = rootNode.path("/ical/horari.ics").getTextValue().toString(); /**Notificacions */ String KEYRegistrar = rootNode.path("/api/subscribeNotificationSystem").getTextValue() .toString(); String KEYDesregistrar = rootNode.path("/api/unsubscribeNotificationSystem").getTextValue() .toString(); SharedPreferences sp = getSharedPreferences(PreferenciesUsuari.getPreferenciesUsuari(), MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); /** Save Username and Password */ editor.putString(AndroidUtils.USERNAME, username); editor.putString(AndroidUtils.PASSWORD, password); /** Save Keys */ editor.putString(au.KEY_AGENDA_RACO_XML, KEYportadaRss); editor.putString(au.KEY_AGENDA_RACO_CAL, KEYportadaCal); editor.putString(au.KEY_AVISOS, KEYavisos); editor.putString(au.KEY_ASSIG_FIB, "public"); editor.putString(au.KEY_ASSIGS_RACO, KEYAssigRaco); editor.putString(au.KEY_HORARI_RACO, KEYIcalHorari); editor.putString(au.KEY_NOTIFICACIONS_REGISTRAR, KEYRegistrar); editor.putString(au.KEY_NOTIFICACIONS_DESREGISTRAR, KEYDesregistrar); /** Save changes */ editor.commit(); } return true; } catch (ProtocolException e) { Toast.makeText(getApplicationContext(), R.string.errorLogin, Toast.LENGTH_LONG).show(); return false; } catch (IOException e) { Toast.makeText(getApplicationContext(), R.string.errorLogin, Toast.LENGTH_LONG).show(); return false; } } }); cancelButton.setOnClickListener(new OnClickListener() { // @Override public void onClick(View v) { Intent act = new Intent(ControladorLoginRaco.this, ControladorTabIniApp.class); act.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); act.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(act); } }); }