List of usage examples for android.content Intent getStringExtra
public String getStringExtra(String name)
From source file:com.carpool.dj.carpool.model.GcmIntentService.java
protected void onMessage(Context context, Intent intent) { HashMap<String, String> NotificationMap = new HashMap<String, String>(); try {// www . j a v a 2 s .c o m this.context = context; String Message = URLDecoder.decode(intent.getStringExtra("message"), "UTF-8"); Log.i("NotificationMap", "message->" + Message); Log.i("NotificationMap", "messageType->" + URLDecoder.decode(intent.getStringExtra("messageType"), "UTF-8")); // if (!message.equals(Message)) { // message = Message; NotificationMap.put("message", Message); NotificationMap.put("timestamp", URLDecoder.decode(intent.getStringExtra("timestamp"), "UTF-8")); NotificationMap.put("accountId", URLDecoder.decode(intent.getStringExtra("accountId"), "UTF-8")); NotificationMap.put("messageType", URLDecoder.decode(intent.getStringExtra("messageType"), "UTF-8")); showGCMMassage(NotificationMap); NotificationHandler.sendMessage(new Message()); if ("CarEvent".equals(intent.getStringExtra("messageType"))) { CarPoolNotificationHandler.sendMessage(new Message()); } // } // } } catch (Exception e) { Utils.ExceptionHandler(e, ContentActivity.tracker, Utils.nowActivity); Log.e(TAG, e.getMessage()); } }
From source file:net.olejon.mdapp.InteractionsCardsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Connected? if (!mTools.isDeviceConnected()) { mTools.showToast(getString(R.string.device_not_connected), 1); finish();//ww w .ja va2 s .co m return; } // Intent final Intent intent = getIntent(); searchString = intent.getStringExtra("search"); // Layout setContentView(R.layout.activity_interactions_cards); // Toolbar mToolbar = (Toolbar) findViewById(R.id.interactions_cards_toolbar); mToolbar.setTitle(getString(R.string.interactions_cards_search) + ": \"" + searchString + "\""); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Progress bar mProgressBar = (ProgressBar) findViewById(R.id.interactions_cards_toolbar_progressbar); mProgressBar.setVisibility(View.VISIBLE); // Refresh mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.interactions_cards_swipe_refresh_layout); mSwipeRefreshLayout.setColorSchemeResources(R.color.accent_blue, R.color.accent_green, R.color.accent_purple, R.color.accent_orange); mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { search(searchString, false); } }); // Recycler view mRecyclerView = (RecyclerView) findViewById(R.id.interactions_cards_cards); mRecyclerView.setHasFixedSize(true); mRecyclerView.setAdapter(new InteractionsCardsAdapter(mContext, mProgressBar, new JSONArray())); mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext)); // No interactions mNoInteractionsLayout = (LinearLayout) findViewById(R.id.interactions_cards_no_interactions); Button noInteractionsButton = (Button) findViewById(R.id.interactions_cards_no_interactions_button); noInteractionsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { Intent intent = new Intent(mContext, MainWebViewActivity.class); intent.putExtra("title", getString(R.string.interactions_cards_search) + ": \"" + searchString + "\""); intent.putExtra("uri", "http://interaksjoner.no/analyser.asp?PreparatNavn=" + URLEncoder.encode(searchString.toLowerCase(), "utf-8") + "&submit1=Sjekk"); mContext.startActivity(intent); } catch (Exception e) { Log.e("InteractionsCards", Log.getStackTraceString(e)); } } }); // Search search(searchString, true); // Correct RequestQueue requestQueue = Volley.newRequestQueue(mContext); try { JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, getString(R.string.project_website_uri) + "api/1/correct/?search=" + URLEncoder.encode(searchString, "utf-8"), new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { try { final String correctSearchString = response.getString("correct"); if (!correctSearchString.equals("")) { new MaterialDialog.Builder(mContext) .title(getString(R.string.correct_dialog_title)) .content(Html.fromHtml(getString(R.string.correct_dialog_message) + ":<br><br><b>" + correctSearchString + "</b>")) .positiveText(getString(R.string.correct_dialog_positive_button)) .negativeText(getString(R.string.correct_dialog_negative_button)) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { ContentValues contentValues = new ContentValues(); contentValues.put(InteractionsSQLiteHelper.COLUMN_STRING, correctSearchString); SQLiteDatabase sqLiteDatabase = new InteractionsSQLiteHelper( mContext).getWritableDatabase(); sqLiteDatabase.delete(InteractionsSQLiteHelper.TABLE, InteractionsSQLiteHelper.COLUMN_STRING + " = " + mTools.sqe(searchString) + " COLLATE NOCASE", null); sqLiteDatabase.insert(InteractionsSQLiteHelper.TABLE, null, contentValues); sqLiteDatabase.close(); mToolbar.setTitle(getString(R.string.interactions_cards_search) + ": \"" + correctSearchString + "\""); mProgressBar.setVisibility(View.VISIBLE); mNoInteractionsLayout.setVisibility(View.GONE); mSwipeRefreshLayout.setVisibility(View.VISIBLE); search(correctSearchString, true); } }).contentColorRes(R.color.black).positiveColorRes(R.color.dark_blue) .negativeColorRes(R.color.black).show(); } } catch (Exception e) { Log.e("InteractionsCards", Log.getStackTraceString(e)); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("InteractionsCards", error.toString()); } }); jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); requestQueue.add(jsonObjectRequest); } catch (Exception e) { Log.e("InteractionsCards", Log.getStackTraceString(e)); } }
From source file:com.example.plugin.PhoneListener.java
public void initialize(CordovaInterface cordova, CordovaWebView webView) { super.initialize(cordova, webView); this.phoneListenerCallbackId = null; IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED); if (this.receiver == null) { this.receiver = new BroadcastReceiver() { @Override/* www. j a va2 s . c o m*/ public void onReceive(Context context, Intent intent) { if (intent != null && intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) { // State has changed String phoneState = intent.hasExtra(TelephonyManager.EXTRA_STATE) ? intent.getStringExtra(TelephonyManager.EXTRA_STATE) : null; String state; // See if the new state is 'ringing', 'off hook' or 'idle' if (phoneState != null && phoneState.equals(TelephonyManager.EXTRA_STATE_RINGING)) { // phone is ringing, awaiting either answering or canceling state = "RINGING"; Log.i(LOG_TAG, state); } else if (phoneState != null && phoneState.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) { // actually talking on the phone... either making a call or having answered one state = "OFFHOOK"; Log.i(LOG_TAG, state); } else if (phoneState != null && phoneState.equals(TelephonyManager.EXTRA_STATE_IDLE)) { // idle means back to no calls in or out. default state. state = "IDLE"; Log.i(LOG_TAG, state); } else { state = TYPE_NONE; Log.i(LOG_TAG, state); } updatePhoneState(state, true); } } }; // register the receiver... this is so it doesn't have to be added to AndroidManifest.xml cordova.getActivity().registerReceiver(this.receiver, intentFilter); this.registered = true; } }
From source file:com.tenforwardconsulting.cordova.bgloc.AbstractLocationService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i(TAG, "Received start id " + startId + ": " + intent); if (intent != null) { config = (Config) intent.getParcelableExtra("config"); activity = intent.getStringExtra("activity"); Log.d(TAG, "Got activity" + activity); // Build a Notification required for running service in foreground. NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setContentTitle(config.getNotificationTitle()); builder.setContentText(config.getNotificationText()); builder.setSmallIcon(android.R.drawable.ic_menu_mylocation); if (config.getNotificationIcon() != null) { builder.setSmallIcon(getPluginResource(config.getSmallNotificationIcon())); builder.setLargeIcon(BitmapFactory.decodeResource(getApplication().getResources(), getPluginResource(config.getLargeNotificationIcon()))); }// www. j a va 2 s. c o m if (config.getNotificationIconColor() != null) { builder.setColor(this.parseNotificationIconColor(config.getNotificationIconColor())); } setClickEvent(builder); Notification notification = builder.build(); notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_FOREGROUND_SERVICE | Notification.FLAG_NO_CLEAR; startForeground(startId, notification); } Log.i(TAG, config.toString()); Log.i(TAG, "- activity: " + activity); //We want this service to continue running until it is explicitly stopped return START_STICKY; }
From source file:com.ola.insta.BookingAcivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getLayoutId());// w w w . j ava 2 s. co m mTextToSpeech = new TextToSpeech(this, this); mUtility = new Utilities(); mProgressDialog = mUtility.GetProcessDialog(this); context = BookingAcivity.this; Intent intent = getIntent(); mCabId = intent.getStringExtra(Constants.CAB_ID); mCabLat = intent.getDoubleExtra(Constants.CAB_LAT, 0.0); mCabLng = intent.getDoubleExtra(Constants.CAB_LANG, 0.0); mCabEta = intent.getLongExtra(Constants.CAB_ETA, 0); init(); }
From source file:com.rukman.emde.smsgroups.authenticator.GMSAuthenticatorActivity.java
/** * {@inheritDoc}//from w w w .j a v a 2s. c om */ @Override public void onCreate(Bundle icicle) { Log.i(TAG, "onCreate(" + icicle + ")"); super.onCreate(icicle); mAccountManager = AccountManager.get(this); Log.i(TAG, "loading data from Intent"); final Intent intent = getIntent(); mUsername = intent.getStringExtra(PARAM_USERNAME); mIsUnknownAccountName = mUsername == null; mConfirmCredentials = intent.getBooleanExtra(PARAM_CONFIRM_CREDENTIALS, false); Log.i(TAG, "IsUnknownAccount? : " + mIsUnknownAccountName); requestWindowFeature(Window.FEATURE_LEFT_ICON); setContentView(R.layout.login_activity); getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_alert); mMessage = (TextView) findViewById(R.id.message); mUsernameEdit = (EditText) findViewById(R.id.username_edit); mPasswordEdit = (EditText) findViewById(R.id.password_edit); mEmailEdit = (EditText) findViewById(R.id.email_edit); mPhoneEdit = (EditText) findViewById(R.id.phone_edit); ((CheckBox) findViewById(R.id.new_account_box)).setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { findViewById(R.id.registration_layout).setVisibility(isChecked ? View.VISIBLE : View.GONE); } }); if (!TextUtils.isEmpty(mUsername)) { mUsernameEdit.setText(mUsername); } mMessage.setText(getMessage()); }
From source file:com.example.h156252.connected_cars.CarGrid.java
/** Called when the activity is first created. */ @Override// w ww .ja va2 s.c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.content_car_grid); try { Window window = getWindow(); // clear FLAG_TRANSLUCENT_STATUS flag: window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); // finally change the color window.setStatusBarColor(Color.rgb(0, 0, 0)); android.support.v7.app.ActionBar actionBar = getSupportActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(Color.rgb(0, 0, 0))); } catch (Exception e) { // Toast.makeText(getApplicationContext(),"Exception in actionbar "+e.getLocalizedMessage(),Toast.LENGTH_SHORT).show(); } session = new SessionManagement(this); tts = new TextToSpeech(this, this); //Toast.makeText(getApplicationContext(),"Entering activity",Toast.LENGTH_SHORT).show(); Intent intent = getIntent(); String result = intent.getStringExtra(HomeScreen.EXTRA_MESSAGE); //Toast.makeText(getApplicationContext(),"obtaining result: " +result,Toast.LENGTH_SHORT).show(); ArrayList<String> listdata = new ArrayList<String>(); try { JSONArray jArray = new JSONArray(result); if (jArray != null) { for (int i = 0; i < jArray.length(); i++) { String jstr = jArray.get(i).toString(); JSONObject jObj = new JSONObject(jstr); String id = jObj.getString("id"); //String phone = jObj.getString("phone"); String brand = jObj.getString("text"); String text = jObj.getString("cartext"); String carno = jObj.getString("carnum"); String color = jObj.getString("color"); //String isDone = jObj.getString("isDone"); String result_combine = "CAR " + i + ":\nCar id : #" + id + "*\n" + "License No. : " + carno + "\n" + "Color : " + color + "\n" + "Brand : " + brand + "\n" + "Text behind car : " + text; String rr = "Success " + result_combine; //Toast.makeText(getApplicationContext(),rr,Toast.LENGTH_SHORT).show(); String own_id = session.getID(); if (!(id.equals(own_id))) listdata.add(result_combine); } } } catch (Exception e) { //Toast.makeText(getApplicationContext(),e.getLocalizedMessage(),Toast.LENGTH_SHORT).show(); } //Toast.makeText(getApplicationContext(),"out of json",Toast.LENGTH_SHORT).show(); final GridView gridview = (GridView) findViewById(R.id.gridview); // final String[] items = new String[] { "Item1", "Item2", "Item3","Item4", "Item5", "Item6", "Item7", "Item8" }; ArrayAdapter<String> ad = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, listdata); //Toast.makeText(getApplicationContext(),"setting array adapter",Toast.LENGTH_SHORT).show(); //gridview.setBackgroundColor(Color.GRAY); gridview.setNumColumns(2); gridview.setGravity(Gravity.CENTER); gridview.setAdapter(ad); gridview.setBackgroundColor(Color.GRAY); //Toast.makeText(getApplicationContext(),"setting grid view",Toast.LENGTH_SHORT).show(); gridview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View v, int position, long arg3) { // TODO Auto-generated method stub // Toast.makeText(getApplicationContext(), "" + arg2,Toast.LENGTH_SHORT).show(); //Toast.makeText(getApplicationContext(),"Prompting speech",Toast.LENGTH_SHORT).show(); try { String s = ((TextView) v).getText().toString(); int start = 0; // '(' position in string int end = 0; // ')' position in string for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == '#') // Looking for '(' position in string start = i; else if (s.charAt(i) == '*') // Looking for ')' position in string end = i; } receiver_id = s.substring(start + 1, end); //Toast.makeText(getApplicationContext(), "ID: " + receiver_id, Toast.LENGTH_SHORT).show(); //promptSpeechInput(); } catch (Exception e) { // Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); } //receiver_id = grid_text.substring(grid_text.indexOf("#") + 1, grid_text.indexOf("#")); //Toast.makeText(getApplicationContext(),receiver_id,Toast.LENGTH_SHORT).show(); try { promptSpeechInput(); } catch (Exception e) { //Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); } try { Intent intent_rate = new Intent(getApplicationContext(), RateDriving.class); intent_rate.putExtra(EXTRA_MESSAGE, receiver_id); startActivity(intent_rate); } catch (Exception e) { //Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); } //new VoiceTask().execute("http://myfirst.au-syd.mybluemix.net/api/Items"); } }); }
From source file:gov.nasa.arc.geocam.geocam.CameraPreviewActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == PICK_ICON_REQUEST) { if (resultCode == RESULT_OK) { int icon_id = data.getIntExtra(FireIconActivity.EXTRA_ID, R.drawable.fire_icon_default); mImageTag = data.getStringExtra(FireIconActivity.EXTRA_TAG); mFireButton.setImageDrawable(getResources().getDrawable(icon_id)); }//from w w w . j ava 2 s. com } }
From source file:com.opemind.cartspage.client.android.book.SearchBookContentsActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Make sure that expired cookies are removed on launch. CookieSyncManager.createInstance(this); CookieManager.getInstance().removeExpiredCookie(); Intent intent = getIntent(); if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) { finish();//from ww w . j a v a2 s. co m return; } isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN); if (LocaleManager.isBookSearchUrl(isbn)) { setTitle(getString(R.string.sbc_name)); } else { setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn); } setContentView(R.layout.search_book_contents); queryTextView = (EditText) findViewById(R.id.query_text_view); String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY); if (initialQuery != null && !initialQuery.isEmpty()) { // Populate the search box but don't trigger the search queryTextView.setText(initialQuery); } queryTextView.setOnKeyListener(keyListener); queryButton = findViewById(R.id.query_button); queryButton.setOnClickListener(buttonListener); resultListView = (ListView) findViewById(R.id.result_list_view); LayoutInflater factory = LayoutInflater.from(this); headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false); resultListView.addHeaderView(headerView); }
From source file:com.sym.demozxing.zxing.book.SearchBookContentsActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Make sure that expired cookies are removed on launch. CookieSyncManager.createInstance(this); CookieManager.getInstance().removeExpiredCookie(); Intent intent = getIntent(); if (intent == null || !Intents.SearchBookContents.ACTION.equals(intent.getAction())) { finish();// w w w . j a va 2 s . c o m return; } isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN); if (LocaleManager.isBookSearchUrl(isbn)) { setTitle(getString(R.string.sbc_name)); } else { setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn); } setContentView(R.layout.search_book_contents); queryTextView = (EditText) findViewById(R.id.query_text_view); String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY); if (initialQuery != null && !initialQuery.isEmpty()) { // Populate the search box but don't trigger the search queryTextView.setText(initialQuery); } queryTextView.setOnKeyListener(keyListener); queryButton = findViewById(R.id.query_button); queryButton.setOnClickListener(buttonListener); resultListView = (ListView) findViewById(R.id.result_list_view); LayoutInflater factory = LayoutInflater.from(this); headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false); resultListView.addHeaderView(headerView); }