List of usage examples for android.content Intent getAction
public @Nullable String getAction()
From source file:com.fvd.nimbus.MainActivity.java
/** Called when the activity is first created. */ @Override/*from ww w . j av a2s . co m*/ public void onCreate(Bundle savedInstanceState) { try { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); try { requestWindowFeature(Window.FEATURE_NO_TITLE); } catch (Exception e) { e.printStackTrace(); } File ex = getExternalCacheDir(); if (ex == null) ex = getCacheDir(); if (ex == null) ex = Environment.getExternalStorageDirectory(); if (ex != null) appSettings.cacheDir = ex.getPath(); setContentView(R.layout.screen_start); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.activity_open_translate, R.anim.activity_close_translate); if (!isTaskRoot()) { Intent intent = getIntent(); String action = intent.getAction(); if (action != null && action.equals(Intent.ACTION_MAIN)) { finish(); return; } } prefs = PreferenceManager.getDefaultSharedPreferences(this); appSettings.getInstance().setIsTablet(isTablet()); serverHelper.getInstance().setCallback(this, this); /*findViewById(R.id.bTakePhoto).setOnClickListener(this); findViewById(R.id.bFromGallery).setOnClickListener(this); findViewById(R.id.bWebClipper).setOnClickListener(this); findViewById(R.id.bPdfAnnotate).setOnClickListener(this); findViewById(R.id.ibSettings).setOnClickListener(this);*/ /*userMail = prefs.getString("userMail", ""); userPass = prefs.getString("userPass", ""); String sessionId = prefs.getString("sessionId", ""); appSettings.sessionId=sessionId; appSettings.userMail=userMail; appSettings.userPass=userPass;*/ appSettings.init(this); userMail = appSettings.userMail; userPass = appSettings.userPass; if (isFirst()) { createShortcut(this); showHelp(); } else if (!prefs.getBoolean("offline", false)) { if ((userMail.length() == 0 || userPass.length() == 0)) showLogin(); else { if (appSettings.sessionId.length() == 0 /*|| true*/) { //serverHelper.getInstance().setSessionId(sessionId); serverHelper.getInstance().sendRequest("user:auth", String.format("\"email\":\"%s\",\"password\":\"%s\"", userMail, userPass), ""); } else { //serverHelper.getInstance().setSessionId(sessionId); serverHelper.getInstance().sendQuietRequest("user:authstate", "", ""); } AppRate.start(this); } } else AppRate.start(this); } catch (Exception e) { appSettings.appendLog("main:onCreate " + e.getMessage()); } }
From source file:io.teak.sdk.service.RavenService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null) { String appId = intent.getStringExtra("appId"); if (appId != null && !appId.isEmpty()) { AppReporter appReporter;//from w w w .j av a 2 s. c o m if (!appReporterMap.containsKey(appId)) { appReporter = new AppReporter(this, appId); appReporterMap.put(appId, appReporter); } else { appReporter = appReporterMap.get(appId); } String action = intent.getAction(); if (action != null && !action.isEmpty()) { if (SET_DSN_INTENT_ACTION.equals(action)) { appReporter.setDsn(intent); } else if (REPORT_EXCEPTION_INTENT_ACTION.equals(action)) { appReporter.reportException(intent); } } } } return START_STICKY; }
From source file:org.quantumbadger.redreader.activities.PostSubmitActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { PrefsUtility.applyTheme(this); super.onCreate(savedInstanceState); final LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.post_submit); typeSpinner = (Spinner) layout.findViewById(R.id.post_submit_type); usernameSpinner = (Spinner) layout.findViewById(R.id.post_submit_username); subredditEdit = (EditText) layout.findViewById(R.id.post_submit_subreddit); titleEdit = (EditText) layout.findViewById(R.id.post_submit_title); textEdit = (EditText) layout.findViewById(R.id.post_submit_body); final Intent intent = getIntent(); if (intent != null) { if (intent.hasExtra("subreddit")) { final String subreddit = intent.getStringExtra("subreddit"); if (subreddit != null && subreddit.length() > 0 && !subreddit.matches("/?(r/)?all/?") && subreddit.matches("/?(r/)?\\w+/?")) { subredditEdit.setText(subreddit); }// w w w .j a va2 s . c o m } else if (intent.getAction().equalsIgnoreCase(Intent.ACTION_SEND) && intent.hasExtra(Intent.EXTRA_TEXT)) { final String url = intent.getStringExtra(Intent.EXTRA_TEXT); textEdit.setText(url); } } else if (savedInstanceState != null && savedInstanceState.containsKey("post_title")) { titleEdit.setText(savedInstanceState.getString("post_title")); textEdit.setText(savedInstanceState.getString("post_body")); subredditEdit.setText(savedInstanceState.getString("subreddit")); typeSpinner.setSelection(savedInstanceState.getInt("post_type")); } final ArrayList<RedditAccount> accounts = RedditAccountManager.getInstance(this).getAccounts(); final ArrayList<String> usernames = new ArrayList<String>(); for (RedditAccount account : accounts) { if (!account.isAnonymous()) { usernames.add(account.username); } } if (usernames.size() == 0) { General.quickToast(this, R.string.error_toast_notloggedin); finish(); } usernameSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, usernames)); typeSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, postTypes)); // TODO remove the duplicate code here setHint(); typeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { setHint(); } public void onNothingSelected(AdapterView<?> parent) { } }); final ScrollView sv = new ScrollView(this); sv.addView(layout); setContentView(sv); }
From source file:fr.bde_eseo.eseomega.lydia.LydiaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // Set view / call parent super.onCreate(savedInstanceState); setContentView(R.layout.activity_lydia); context = this; // Init intent flag INTENT_REQUEST intent_request = INTENT_REQUEST.ERROR; // Get intent parameters if (savedInstanceState == null) { Intent intent = getIntent(); Bundle extras = intent.getExtras(); String action = intent.getAction(); if (action != null) { // Check if intent's action is correct (obviously yes, but prevents Manifest modifications) if (action.equals(Intent.ACTION_VIEW)) { // Intent depuis Lydia intent_request = INTENT_REQUEST.FROM_LYDIA; // Get all parameters Uri qUri = intent.getData(); // Order ID String sOrderID = qUri.getQueryParameter("id"); if (sOrderID != null) { orderID = Integer.parseInt(sOrderID); }// w ww . j ava2s . c o m orderType = qUri.getQueryParameter("cat"); } } else if (extras != null) { // Intent interne intent_request = INTENT_REQUEST.FROM_APP; orderID = extras.getInt(Constants.KEY_LYDIA_ORDER_ID); orderType = extras.getString(Constants.KEY_LYDIA_ORDER_TYPE); // Demande de check ? donc ask dj effectu if (extras.getBoolean(Constants.KEY_LYDIA_ORDER_ASKED)) { intent_request = INTENT_REQUEST.FROM_LYDIA; } } } // No intent received if (intent_request == INTENT_REQUEST.ERROR || orderID == -1) { Toast.makeText(context, "Erreur de l'application (c'est pas normal)", Toast.LENGTH_SHORT).show(); close(); } // Get objects userProfile = new UserProfile(); userProfile.readProfilePromPrefs(context); prefsUser = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); // Init dialog dialogInit(); // Get intent type if (intent_request == INTENT_REQUEST.FROM_APP) { /** * FROM_APP : On doit demander le numro de tlphone du client, puis lorsqu'il clique sur "Payer", effectuer une demande de paiement auprs de Lydia. * Il faut ensuite lancer l'Intent vers Lydia avec le bon numro de requte. * * A afficher : * - InputText tlphone * - Checkbox mmorisation numro * - Texte "lgal" sur le numro de tlphone * - Boutons Annuler / Valider AsyncTask ask.php */ dialogFromApp(); } else { /** * FROM_LYDIA : L'activit vient d'tre ouverte aprs que le client ait cliqu sur "Accepter" depuis l'app Lydia. * Dans 100% des cas, le retour notre activit se fait si il a eu un paiement valid. * Cependant, on vrifiera le statut de la commande auprs de notre serveur malgr tout. * * A afficher : * - Texte "tat de votre commande" titre dialogue * - Texte status : actualis toutes les 3 secondes asyncTask * - Bouton Fermer si status diffrent de "en cours" */ dialogFromLydia(); } }
From source file:com.timemachine.controller.ControllerActivity.java
private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String input = intent.getStringExtra(SearchManager.QUERY); String suggestion = (String) intent.getExtras().get("intent_extra_data_key"); String query;/*from ww w.ja v a 2 s . co m*/ // Use the query to search your data somehow if (suggestion == null) query = input; else query = suggestion; Geocoder geocoder = new Geocoder(ControllerActivity.this); try { List<Address> address = geocoder.getFromLocationName(query, 1); if (address != null && !address.isEmpty()) { Address location = address.get(0); System.out.println(location.getLatitude() + ", " + location.getLongitude()); mMap.animateCamera( CameraUpdateFactory.newLatLngZoom( new LatLng(location.getLatitude(), location.getLongitude()), maxZoom), animateCameraDuration, null); } else System.out.println("No address found."); } catch (IOException e) { e.printStackTrace(); } } }
From source file:ca.mudar.parkcatcher.ui.fragments.DetailsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); activityHelper = ActivityHelper.createInstance(getActivity()); parkingApp = (ParkingApp) getActivity().getApplicationContext(); Intent intent = getSherlockActivity().getIntent(); // TODO Optimize this using savedInstanceState to avoid reload of // identical data onResume if (Intent.ACTION_VIEW.equals(intent.getAction())) { mIdPost = getIdFromUri(intent.getData()); }//w ww.ja va 2s.c om // else if ((savedInstanceState != null) // && savedInstanceState.containsKey(Const.KEY_INSTANCE_RINK_ID)) { // mRinkId = savedInstanceState.getInt(Const.KEY_INSTANCE_RINK_ID); // } else { mIdPost = intent.getIntExtra(Const.INTENT_EXTRA_POST_ID, -1); } // mUriPost = Posts.buildPostUri(Integer.toString(mIdPost)); getLoaderManager().initLoader(PostDetailsQuery._TOKEN, null, this); }
From source file:it.feio.android.omninotes.async.DataBackupIntentService.java
/** * Creation of notification on operations completed *///from w ww . ja v a 2 s .c o m private void createNotification(Intent intent, Context mContext, String title, String message, File backupDir) { // The behavior differs depending on intent action Intent intentLaunch; if (DataBackupIntentService.ACTION_DATA_IMPORT.equals(intent.getAction()) || DataBackupIntentService.ACTION_DATA_IMPORT_SPRINGPAD.equals(intent.getAction())) { intentLaunch = new Intent(mContext, MainActivity.class); intentLaunch.setAction(Constants.ACTION_RESTART_APP); } else { intentLaunch = new Intent(); } // Add this bundle to the intent intentLaunch.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intentLaunch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Creates the PendingIntent PendingIntent notifyIntent = PendingIntent.getActivity(mContext, 0, intentLaunch, PendingIntent.FLAG_UPDATE_CURRENT); NotificationsHelper mNotificationsHelper = new NotificationsHelper(mContext); mNotificationsHelper.createNotification(R.drawable.ic_content_save_white_24dp, title, notifyIntent) .setMessage(message).setRingtone(prefs.getString("settings_notification_ringtone", null)) .setLedActive(); if (prefs.getBoolean("settings_notification_vibration", true)) mNotificationsHelper.setVibration(); mNotificationsHelper.show(); }
From source file:ca.mudar.parkcatcher.ui.fragments.DetailsFragment.java
@Override public void onResume() { super.onResume(); mHandler = new NotifyingAsyncQueryHandler(getActivity().getContentResolver(), this); Intent intent = getSherlockActivity().getIntent(); // TODO Optimize this using savedInstanceState to avoid reload of // identical data onResume if (Intent.ACTION_VIEW.equals(intent.getAction())) { mIdPost = getIdFromUri(intent.getData()); }//from w w w. j a v a 2 s . c o m // else if ((savedInstanceState != null) // && savedInstanceState.containsKey(Const.KEY_INSTANCE_RINK_ID)) { // mRinkId = savedInstanceState.getInt(Const.KEY_INSTANCE_RINK_ID); // } else { mIdPost = intent.getIntExtra(Const.INTENT_EXTRA_POST_ID, -1); } // mUriPost = Posts.buildPostUri(Integer.toString(mIdPost)); final GregorianCalendar calendar = parkingApp.getParkingCalendar(); final int duration = parkingApp.getParkingDuration(); ((TextView) mView.findViewById(R.id.details_time_title)) .setText(ParkingTimeHelper.getTitle(this.getActivity(), calendar, duration)); }
From source file:org.lol.reddit.activities.PostSubmitActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { PrefsUtility.applyTheme(this); super.onCreate(savedInstanceState); final LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.post_submit); typeSpinner = (Spinner) layout.findViewById(R.id.post_submit_type); usernameSpinner = (Spinner) layout.findViewById(R.id.post_submit_username); subredditEdit = (EditText) layout.findViewById(R.id.post_submit_subreddit); titleEdit = (EditText) layout.findViewById(R.id.post_submit_title); textEdit = (EditText) layout.findViewById(R.id.post_submit_body); final Intent intent = getIntent(); if (intent != null) { if (intent.hasExtra("subreddit")) { final String subreddit = intent.getStringExtra("subreddit"); if (subreddit != null && subreddit.length() > 0 && !subreddit.matches("/?(r/)?all/?") && subreddit.matches("/?(r/)?\\w+/?")) { subredditEdit.setText(subreddit); }//from w ww . ja v a 2s . c o m } else if (Intent.ACTION_SEND.equalsIgnoreCase(intent.getAction()) && intent.hasExtra(Intent.EXTRA_TEXT)) { final String url = intent.getStringExtra(Intent.EXTRA_TEXT); textEdit.setText(url); } } else if (savedInstanceState != null && savedInstanceState.containsKey("post_title")) { titleEdit.setText(savedInstanceState.getString("post_title")); textEdit.setText(savedInstanceState.getString("post_body")); subredditEdit.setText(savedInstanceState.getString("subreddit")); typeSpinner.setSelection(savedInstanceState.getInt("post_type")); } final ArrayList<RedditAccount> accounts = RedditAccountManager.getInstance(this).getAccounts(); final ArrayList<String> usernames = new ArrayList<String>(); for (RedditAccount account : accounts) { if (!account.isAnonymous()) { usernames.add(account.username); } } if (usernames.size() == 0) { General.quickToast(this, R.string.error_toast_notloggedin); finish(); } usernameSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, usernames)); typeSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, postTypes)); // TODO remove the duplicate code here setHint(); typeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { setHint(); } public void onNothingSelected(AdapterView<?> parent) { } }); final ScrollView sv = new ScrollView(this); sv.addView(layout); setContentView(sv); }