List of usage examples for android.content Intent getStringExtra
public String getStringExtra(String name)
From source file:com.szanata.cordova.phonestatechangelistener.PhoneStateChangeListener.java
/** * creates a new BroadcastReceiver to listen whether the Telephony State changes *//*from w w w . j ava 2 s . co m*/ public void startPhoneListener(final CallbackContext callbackContext) { if (this.receiver == null) { this.receiver = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { if (intent != null && intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) { String state = intent.hasExtra(TelephonyManager.EXTRA_STATE) ? intent.getStringExtra(TelephonyManager.EXTRA_STATE) : NONE; String number = ""; if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) { number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); } final JSONObject data = new JSONObject(); try { data.put("state", state); data.put("number", number); callbackContext.success(data); } catch (final JSONException e) { callbackContext.error(e.getMessage()); } } } }; this.context.registerReceiver(this.receiver, new IntentFilter(TelephonyManager.ACTION_PHONE_STATE_CHANGED)); } }
From source file:fr.mdk.kisspush.KISSPush.java
public void onRegIdAvailable(String reg_id) { kiss_push_cli.set_reg_id(reg_id);//from w ww . j av a 2 s . c om kiss_push_cli.register(); Intent intent = getIntent(); String channel = intent.getStringExtra(KISSPush.MESSAGE_CHANNEL_NAME); if (channel != null) { kiss_push_cli.delete_alias(channel, new JsonHttpResponseHandler() { @Override public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { getAliases(); } }); } else { getAliases(); } }
From source file:fi.hut.soberit.sensors.uploaders.PlaygroundUploader.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d(TAG, "onStartCommand"); int res = super.onStartCommand(intent, flags, startId); if (intent == null) { return res; }/*from ww w . j a v a 2s . c o m*/ final StringBuilder builder = new StringBuilder(); builder.append(intent.getStringExtra(INTENT_AHL_URL)); builder.append("?"); builder.append("username="); builder.append(intent.getStringExtra(INTENT_USERNAME)); builder.append("&"); builder.append("password="); builder.append(intent.getStringExtra(INTENT_PASSWORD)); final String weblet = intent.getStringExtra(INTENT_WEBLET); if (weblet != null) { builder.append("&"); builder.append("weblet="); builder.append(weblet); } baseUrl = builder.toString(); Log.d(TAG, "baseUrl:" + baseUrl); client = ((WithHttpClient) getApplication()).getHttpClient(); return res; }
From source file:com.szanata.cordova.plugins.PhoneStateChangeListener.java
/** * creates a new BroadcastReceiver to listen whether the Telephony State changes *//*from ww w.j a va 2 s . c o m*/ public void startPhoneListener() { if (this.receiver == null) { this.receiver = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { if (intent != null && intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) { String state = intent.hasExtra(TelephonyManager.EXTRA_STATE) ? intent.getStringExtra(TelephonyManager.EXTRA_STATE) : NONE; String number = ""; if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) { number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); } if (callbackContext != null) { final JSONObject data = new JSONObject(); try { data.put("state", state); data.put("number", number); } catch (final JSONException e) { } ; callbackContext.success(data); } } } }; this.context.registerReceiver(this.receiver, new IntentFilter(TelephonyManager.ACTION_PHONE_STATE_CHANGED)); } }
From source file:com.jonbanjo.cupsprint.CertificateActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_certificate); host = (EditText) findViewById(R.id.cert_host_edit); port = (EditText) findViewById(R.id.cert_port_edit); certList = (ListView) findViewById(R.id.cert_list); importButton = (Button) findViewById(R.id.cert_import); Intent intent = getIntent(); String ip = intent.getStringExtra("host"); if (ip != null) { host.setText(ip);/*from w w w . j a v a2 s. co m*/ } String pt = intent.getStringExtra("port"); if (pt != null) { port.setText(pt); } trustStore = loadTrustStore(); if (trustStore == null) { return; } ArrayList<String> certArray; try { certArray = Collections.list(trustStore.aliases()); } catch (Exception e) { return; } certListAdaptor = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, certArray); certList.setAdapter(certListAdaptor); certList.setClickable(true); certList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { displayCert(certListAdaptor.getItem(position)); } }); }
From source file:com.cloudstudio.BarcodeScanner.java
/** * Called when the barcode scanner intent completes. * * @param requestCode The request code originally supplied to startActivityForResult(), * allowing you to identify who this result came from. * @param resultCode The integer result code returned by the child activity through its setResult(). * @param intent An Intent, which can return result data to the caller (various data can be attached to Intent "extras"). *//*from w w w .j av a2 s . c om*/ @Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == REQUEST_CODE) { if (resultCode == Activity.RESULT_OK) { JSONObject obj = new JSONObject(); try { obj.put(TEXT, intent.getStringExtra("SCAN_RESULT")); obj.put(FORMAT, intent.getStringExtra("SCAN_RESULT_FORMAT")); obj.put(CANCELLED, false); } catch (JSONException e) { Log.d(LOG_TAG, "This should never happen"); } //this.success(new PluginResult(PluginResult.Status.OK, obj), this.callback); this.callbackContext.success(obj); } else if (resultCode == Activity.RESULT_CANCELED) { JSONObject obj = new JSONObject(); try { obj.put(TEXT, ""); obj.put(FORMAT, ""); obj.put(CANCELLED, true); } catch (JSONException e) { Log.d(LOG_TAG, "This should never happen"); } //this.success(new PluginResult(PluginResult.Status.OK, obj), this.callback); this.callbackContext.success(obj); } else { //this.error(new PluginResult(PluginResult.Status.ERROR), this.callback); this.callbackContext.error("Unexpected error"); } } }
From source file:com.scigames.slidegame.Registration5EmailActivity.java
/** Called with the activity is first created. */ @Override//from w w w . ja v a 2s . c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "super.OnCreate"); Intent i = getIntent(); Log.d(TAG, "getIntent"); firstNameIn = i.getStringExtra("fName"); lastNameIn = i.getStringExtra("lName"); studentIdIn = i.getStringExtra("studentId"); visitIdIn = i.getStringExtra("visitId"); Log.d(TAG, "...getStringExtra"); // Inflate our UI from its XML layout description. setContentView(R.layout.registration5_email); Log.d(TAG, "...setContentView"); email = (EditText) findViewById(R.id.email); /* to hide the keyboard on launch, then open when tap in firstname field */ email.setInputType(InputType.TYPE_NULL); email.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { email.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); email.onTouchEvent(event); // call native handler return true; // consume touch even } }); Log.d(TAG, "...instantiateEditTexts"); //display name in greeting sentence Resources res = getResources(); TextView greets = (TextView) findViewById(R.id.greeting); greets.setText(String.format(res.getString(R.string.greeting), firstNameIn, lastNameIn)); Log.d(TAG, greets.toString()); Log.d(TAG, "...Greetings"); // Hook up button presses to the appropriate event handler. ((Button) findViewById(R.id.back)).setOnClickListener(mBackListener); ((Button) findViewById(R.id.continue_button)).setOnClickListener(mContinueButtonListener); Log.d(TAG, "...instantiateButtons"); //set listener task.setOnResultsListener(this); }
From source file:at.bitfire.davdroid.ui.setup.LoginCredentialsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.login_credentials_fragment, container, false); radioUseEmail = (RadioButton) v.findViewById(R.id.login_type_email); emailDetails = (LinearLayout) v.findViewById(R.id.login_type_email_details); editEmailAddress = (EditText) v.findViewById(R.id.email_address); editEmailPassword = (EditPassword) v.findViewById(R.id.email_password); radioUseURL = (RadioButton) v.findViewById(R.id.login_type_url); urlDetails = (LinearLayout) v.findViewById(R.id.login_type_url_details); editBaseURL = (EditText) v.findViewById(R.id.base_url); editUserName = (EditText) v.findViewById(R.id.user_name); editUrlPassword = (EditPassword) v.findViewById(R.id.url_password); radioUseEmail.setOnCheckedChangeListener(this); radioUseURL.setOnCheckedChangeListener(this); if (savedInstanceState == null) { // first call Activity activity = getActivity(); Intent intent = (activity != null) ? activity.getIntent() : null; if (intent != null) { // we've got initial login data String url = intent.getStringExtra(LoginActivity.EXTRA_URL), username = intent.getStringExtra(LoginActivity.EXTRA_USERNAME), password = intent.getStringExtra(LoginActivity.EXTRA_PASSWORD); if (url != null) { radioUseURL.setChecked(true); editBaseURL.setText(url); editUserName.setText(username); editUrlPassword.setText(password); } else { radioUseEmail.setChecked(true); editEmailAddress.setText(username); editEmailPassword.setText(password); }/*from w w w. j av a 2s. c om*/ } else radioUseEmail.setChecked(true); } final Button login = (Button) v.findViewById(R.id.login); login.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { LoginCredentials credentials = validateLoginData(); if (credentials != null) DetectConfigurationFragment.newInstance(credentials).show(getFragmentManager(), null); } }); return v; }
From source file:com.madgag.agit.CloneLauncherActivity.java
private void setGitDirFrom(Intent intent) { String gitdir = intent.getStringExtra(EXTRA_TARGET_DIR); useDefaultGitDirLocationButton.setChecked(gitdir == null); if (gitdir != null) { gitDirEditText.setText(gitdir);// w ww . j av a2 s.co m Log.d(TAG, "Set gitdir to " + gitdir); } }
From source file:com.androidquery.simplefeed.activity.ImageActivity.java
@Override protected void init(Bundle savedInstanceState) { initView();//from w w w .j av a 2 s . co m Intent intent = getIntent(); if (intent == null) return; String url = intent.getStringExtra("url"); if (url == null) return; item = (FeedItem) intent.getSerializableExtra("item"); if (item != null) { if ("photo".equals(item.getType())) { url = handle.getNetworkUrl(url); } if (item.getSource() == null) { item.setSource(url); item.setItemName(item.getDesc()); } photos.add(item); adapter.notifyDataSetChanged(); boolean fetchAlbum = intent.getBooleanExtra("album", true); String album = extractAlbum(item); if (fetchAlbum && album != null) { ajaxPhoto(album, HALF_DAY); } } }