List of usage examples for android.content Intent getStringExtra
public String getStringExtra(String name)
From source file:io.v.android.apps.account_manager.AccountActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE_PICK_ACCOUNTS) { if (resultCode != RESULT_OK) { replyWithError("User didn't pick account."); return; }/* w w w . jav a2 s. c o m*/ mAccountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); getIdentity(); } else if (requestCode == REQUEST_CODE_USER_APPROVAL) { if (resultCode != RESULT_OK) { replyWithError("User didn't give proposed permissions."); return; } getIdentity(); } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.ronnyml.sweetplayer.fragments.SearchFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_search, container, false); mActivity = this.getActivity(); mArtistsRecyclerView = (RecyclerView) rootView.findViewById(R.id.top_artists_recyclerview); mEditText = (EditText) rootView.findViewById(R.id.search_edit_text); mLoadingBar = (ProgressBar) rootView.findViewById(R.id.loading_bar); mSearchButton = (ImageButton) rootView.findViewById(R.id.search_button); mSongsListview = (ObservableListView) rootView.findViewById(R.id.songs_listview); mTopArtistsLayout = (LinearLayout) rootView.findViewById(R.id.top_artists_layout); mTopSongsLayout = (LinearLayout) rootView.findViewById(R.id.top_songs_layout); LinearLayoutManager mArtistsLinearLayoutManager = new LinearLayoutManager( mActivity.getApplicationContext()); mArtistsLinearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); mArtistsRecyclerView.setLayoutManager(mArtistsLinearLayoutManager); mArtistsRecyclerView.setItemAnimator(new DefaultItemAnimator()); mSongsListview.setScrollViewCallbacks(this); setupSearchButton();/*from w w w . ja v a2s . c o m*/ if (Utils.isConnectedToInternet(mActivity)) { Intent intent = mActivity.getIntent(); if (intent != null) { if (intent.getBooleanExtra(Constants.IS_SEARCH, false)) { search(intent.getStringExtra(Constants.SEARCH_TEXT)); } else { getRequest(Constants.ARTISTS_URL, 0); getRequest(Constants.TOP_URL, 1); } } } else { Utils.showAlertDialog(mActivity, mActivity.getString(R.string.internet_no_connection_title), mActivity.getString(R.string.internet_no_connection_message)); } return rootView; }
From source file:fr.enseirb.odroidx.videomanager.Uploader.java
public void onStart(Intent uploadintent, int startId) { //Getting data to send to the message queue Message msg = mUploadHandler.obtainMessage(); msg.arg1 = startId;/*from ww w. ja va 2s . c o m*/ //Putting IRU in message for handler msg.obj = uploadintent.getData(); server_ip = uploadintent.getStringExtra("IP"); Log.d("uploader", "server ip : " + server_ip); if (server_ip == null) { Log.e(getClass().getSimpleName(), "IP null"); Toast.makeText(Uploader.this, R.string.menu_ip, Toast.LENGTH_SHORT).show(); } else { mUploadHandler.sendMessage(msg); Log.d(getClass().getSimpleName(), "Sending: " + msg); } }
From source file:io.clh.lrt.androidservice.TraceListenerService.java
private void traceEvent(Context context, Intent intent) { JSONObject jsonData = new JSONObject(); try {/*from w w w . j av a2 s.c om*/ String appName = intent.getStringExtra("appName"); if (appLut.get(appName) == null) { intent.putExtra("appVersion", "UNKNOWN"); traceEventStart(context, intent); return; } jsonData.put("methodSig", intent.getStringExtra("methodSig")); jsonData.put("timestamp", intent.getStringExtra("timestamp")); jsonData.put("fileName", intent.getStringExtra("fileName")); jsonData.put("lineNumber", intent.getIntExtra("lineNumber", -1)); jsonData.put("seq", intent.getIntExtra("seq", -1)); JSONArray jsonArray = new JSONArray(); jsonArray.put(jsonData); Log.d(TAG, "trace event: " + jsonData.toString()); HttpResponse response = postAPI("traces/" + appLut.get(appName) + "/tracepoints", "trace", jsonArray.toString()); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.example.bluetoothlegatt.DeviceControlActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.gatt_services_characteristics); setContentView(R.layout.pic_layout); // UNIVERSAL IMAGE LOADER SETUP DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().cacheOnDisc().cacheInMemory() .imageScaleType(ImageScaleType.EXACTLY).displayer(new FadeInBitmapDisplayer(300)).build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) .defaultDisplayImageOptions(defaultOptions).memoryCache(new WeakMemoryCache()) .discCacheSize(100 * 1024 * 1024).build(); ImageLoader.getInstance().init(config); // END - UNIVERSAL IMAGE LOADER SETUP iml = ImageLoader.getInstance();//from w w w. jav a 2 s . co m dmp = new DisplayImageOptions.Builder().cacheInMemory().cacheOnDisc().resetViewBeforeLoading() .showImageForEmptyUri(R.drawable.ic_launcher).build(); final Intent intent = getIntent(); mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME); mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS); mDevicePromotion = intent.getStringExtra(EXTRAS_DEVICE_PROMOTION); // Sets up UI references. // ((TextView) findViewById(R.id.device_address)).setText(mDeviceAddress); // mGattServicesList = (ExpandableListView) findViewById(R.id.gatt_services_list); // mGattServicesList.setOnChildClickListener(servicesListClickListner); // mConnectionState = (TextView) findViewById(R.id.connection_state); // mDataField = (TextView) findViewById(R.id.data_value);klll promo = (ImageView) findViewById(R.id.promotion); getActionBar().setTitle(mDeviceName); getActionBar().setDisplayHomeAsUpEnabled(true); Intent gattServiceIntent = new Intent(this, BluetoothLeService.class); //bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE); // connect to server //this.getBTInfo(this.mDeviceAddress); // connected to server 2 //this.getBTInfo2(this.mDeviceAddress ,this.mDeviceAndroid ); iml.displayImage(mDevicePromotion, promo, dmp); }
From source file:com.pixmob.r2droid.DeviceRegistrationService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { final String action = intent.getAction(); if (ACTION_C2DM_ERROR.equals(action)) { onC2DMError(intent.getStringExtra(KEY_ERROR)); } else if (action != null) { return super.onStartCommand(intent, flags, startId); }/*from ww w. ja va 2 s . c om*/ return START_NOT_STICKY; }
From source file:de.incoherent.suseconferenceclient.tasks.CheckForUpdatesTask.java
@Override protected Long doInBackground(Void... params) { String kUrl = "https://conference.opensuse.org/osem/api/v1/conferences/gRNyOIsTbvCfJY5ENYovBA"; if (kUrl.length() <= 0) return 0l; String updatesUrl = mConference.getUrl() + "/updates.json"; int lastUpdateRevision = mDb.getLastUpdateValue(mConference.getSqlId()); int revisionLevel = lastUpdateRevision; try {//from w w w . j a v a2 s . com JSONObject updateReply = HTTPWrapper.get(updatesUrl); if (updateReply == null) return 0l; int newLevel = updateReply.getInt("revision"); if (newLevel > revisionLevel) { long id = mConference.getSqlId(); // Cache favorites and alerts List<String> favoriteGuids = mDb.getFavoriteGuids(id); List<Event> alerts = mDb.getAlertEvents(id); List<String> alertGuids = new ArrayList<String>(); // Now cancel all of the outstanding alerts, in case // a talk has been moved AlarmManager manager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); for (Event e : alerts) { alertGuids.add("\"" + e.getGuid() + "\""); Log.d("SUSEConferences", "Removing an alert for " + e.getTitle()); Intent intent = new Intent(mContext, AlarmReceiver.class); intent.putExtras(ScheduleDetailsActivity.generateAlarmIntentBundle(mContext, e)); PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, intent.getStringExtra("intentId").hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT); manager.cancel(pendingIntent); pendingIntent.cancel(); } // Now clear the DB mDb.clearDatabase(id); // Download schedule ConferenceCacher cacher = new ConferenceCacher(new ConferenceCacherProgressListener() { @Override public void progress(String progress) { publishProgress(progress); } }); long val = cacher.cacheConference(mConference, mDb); mErrorMessage = cacher.getLastError(); if (val == -1) { mDb.setConferenceAsCached(id, 0); } else { mDb.setLastUpdateValue(id, newLevel); mDb.toggleEventsInMySchedule(favoriteGuids); mDb.toggleEventAlerts(alertGuids); alerts = mDb.getAlertEvents(id); // ... And re-create the alerts, if they are in the future Date currentDate = new Date(); for (Event e : alerts) { if (currentDate.after(e.getDate())) continue; Log.d("SUSEConferences", "Adding an alert for " + e.getTitle()); alertGuids.add("\"" + e.getGuid() + "\""); Intent intent = new Intent(mContext, AlarmReceiver.class); intent.putExtras(ScheduleDetailsActivity.generateAlarmIntentBundle(mContext, e)); PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, intent.getStringExtra("intentId").hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT); manager.set(AlarmManager.RTC_WAKEUP, e.getDate().getTime() - 300000, pendingIntent); } } return val; } else { return 0l; } } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SocketException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:com.sip.pwc.sipphone.service.Downloader.java
@Override protected void onHandleIntent(Intent intent) { HttpGet getMethod = new HttpGet(intent.getData().toString()); int result = Activity.RESULT_CANCELED; String outPath = intent.getStringExtra(EXTRA_OUTPATH); boolean checkMd5 = intent.getBooleanExtra(EXTRA_CHECK_MD5, false); int icon = intent.getIntExtra(EXTRA_ICON, 0); String title = intent.getStringExtra(EXTRA_TITLE); boolean showNotif = (icon > 0 && !TextUtils.isEmpty(title)); // Build notification Builder nb = new Builder(this); nb.setWhen(System.currentTimeMillis()); nb.setContentTitle(title);/* ww w. j a v a2 s . com*/ nb.setSmallIcon(android.R.drawable.stat_sys_download); nb.setOngoing(true); Intent i = new Intent(this, SipHome.class); nb.setContentIntent(PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT)); RemoteViews contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.download_notif); contentView.setImageViewResource(R.id.status_icon, icon); contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.downloading_text)); contentView.setProgressBar(R.id.status_progress, 50, 0, false); contentView.setViewVisibility(R.id.status_progress_wrapper, View.VISIBLE); nb.setContent(contentView); final Notification notification = showNotif ? nb.build() : null; notification.contentView = contentView; if (!TextUtils.isEmpty(outPath)) { try { File output = new File(outPath); if (output.exists()) { output.delete(); } if (notification != null) { notificationManager.notify(NOTIF_DOWNLOAD, notification); } ResponseHandler<Boolean> responseHandler = new FileStreamResponseHandler(output, new Progress() { private int oldState = 0; @Override public void run(long progress, long total) { //Log.d(THIS_FILE, "Progress is "+progress+" on "+total); int newState = (int) Math.round(progress * 50.0f / total); if (oldState != newState) { notification.contentView.setProgressBar(R.id.status_progress, 50, newState, false); notificationManager.notify(NOTIF_DOWNLOAD, notification); oldState = newState; } } }); boolean hasReply = client.execute(getMethod, responseHandler); if (hasReply) { if (checkMd5) { URL url = new URL(intent.getData().toString().concat(".md5sum")); InputStream content = (InputStream) url.getContent(); if (content != null) { BufferedReader br = new BufferedReader(new InputStreamReader(content)); String downloadedMD5 = ""; try { downloadedMD5 = br.readLine().split(" ")[0]; } catch (NullPointerException e) { throw new IOException("md5_verification : no sum on server"); } if (!MD5.checkMD5(downloadedMD5, output)) { throw new IOException("md5_verification : incorrect"); } } } PendingIntent pendingIntent = (PendingIntent) intent .getParcelableExtra(EXTRA_PENDING_FINISH_INTENT); try { Runtime.getRuntime().exec("chmod 644 " + outPath); } catch (IOException e) { Log.e(THIS_FILE, "Unable to make the apk file readable", e); } Log.d(THIS_FILE, "Download finished of : " + outPath); if (pendingIntent != null) { notification.contentIntent = pendingIntent; notification.flags = Notification.FLAG_AUTO_CANCEL; notification.icon = android.R.drawable.stat_sys_download_done; notification.contentView.setViewVisibility(R.id.status_progress_wrapper, View.GONE); notification.contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.done) // TODO should be a parameter of this class + " - Click to install"); notificationManager.notify(NOTIF_DOWNLOAD, notification); /* try { pendingIntent.send(); notificationManager.cancel(NOTIF_DOWNLOAD); } catch (CanceledException e) { Log.e(THIS_FILE, "Impossible to start pending intent for download finish"); } */ } else { Log.w(THIS_FILE, "Invalid pending intent for finish !!!"); } result = Activity.RESULT_OK; } } catch (IOException e) { Log.e(THIS_FILE, "Exception in download", e); } } if (result == Activity.RESULT_CANCELED) { notificationManager.cancel(NOTIF_DOWNLOAD); } }
From source file:com.csipsimple.service.Downloader.java
@Override protected void onHandleIntent(Intent intent) { HttpGet getMethod = new HttpGet(intent.getData().toString()); int result = Activity.RESULT_CANCELED; String outPath = intent.getStringExtra(EXTRA_OUTPATH); boolean checkMd5 = intent.getBooleanExtra(EXTRA_CHECK_MD5, false); int icon = intent.getIntExtra(EXTRA_ICON, 0); String title = intent.getStringExtra(EXTRA_TITLE); boolean showNotif = (icon > 0 && !TextUtils.isEmpty(title)); // Build notification Builder nb = new NotificationCompat.Builder(this); nb.setWhen(System.currentTimeMillis()); nb.setContentTitle(title);// w w w .j a va 2 s . c o m nb.setSmallIcon(android.R.drawable.stat_sys_download); nb.setOngoing(true); Intent i = new Intent(this, SipHome.class); nb.setContentIntent(PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT)); RemoteViews contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.download_notif); contentView.setImageViewResource(R.id.status_icon, icon); contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.downloading_text)); contentView.setProgressBar(R.id.status_progress, 50, 0, false); contentView.setViewVisibility(R.id.status_progress_wrapper, View.VISIBLE); nb.setContent(contentView); final Notification notification = showNotif ? nb.build() : null; notification.contentView = contentView; if (!TextUtils.isEmpty(outPath)) { try { File output = new File(outPath); if (output.exists()) { output.delete(); } if (notification != null) { notificationManager.notify(NOTIF_DOWNLOAD, notification); } ResponseHandler<Boolean> responseHandler = new FileStreamResponseHandler(output, new Progress() { private int oldState = 0; @Override public void run(long progress, long total) { //Log.d(THIS_FILE, "Progress is "+progress+" on "+total); int newState = (int) Math.round(progress * 50.0f / total); if (oldState != newState) { notification.contentView.setProgressBar(R.id.status_progress, 50, newState, false); notificationManager.notify(NOTIF_DOWNLOAD, notification); oldState = newState; } } }); boolean hasReply = client.execute(getMethod, responseHandler); if (hasReply) { if (checkMd5) { URL url = new URL(intent.getData().toString().concat(".md5sum")); InputStream content = (InputStream) url.getContent(); if (content != null) { BufferedReader br = new BufferedReader(new InputStreamReader(content)); String downloadedMD5 = ""; try { downloadedMD5 = br.readLine().split(" ")[0]; } catch (NullPointerException e) { throw new IOException("md5_verification : no sum on server"); } if (!MD5.checkMD5(downloadedMD5, output)) { throw new IOException("md5_verification : incorrect"); } } } PendingIntent pendingIntent = (PendingIntent) intent .getParcelableExtra(EXTRA_PENDING_FINISH_INTENT); try { Runtime.getRuntime().exec("chmod 644 " + outPath); } catch (IOException e) { Log.e(THIS_FILE, "Unable to make the apk file readable", e); } Log.d(THIS_FILE, "Download finished of : " + outPath); if (pendingIntent != null) { notification.contentIntent = pendingIntent; notification.flags = Notification.FLAG_AUTO_CANCEL; notification.icon = android.R.drawable.stat_sys_download_done; notification.contentView.setViewVisibility(R.id.status_progress_wrapper, View.GONE); notification.contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.done) // TODO should be a parameter of this class + " - Click to install"); notificationManager.notify(NOTIF_DOWNLOAD, notification); /* try { pendingIntent.send(); notificationManager.cancel(NOTIF_DOWNLOAD); } catch (CanceledException e) { Log.e(THIS_FILE, "Impossible to start pending intent for download finish"); } */ } else { Log.w(THIS_FILE, "Invalid pending intent for finish !!!"); } result = Activity.RESULT_OK; } } catch (IOException e) { Log.e(THIS_FILE, "Exception in download", e); } } if (result == Activity.RESULT_CANCELED) { notificationManager.cancel(NOTIF_DOWNLOAD); } }