List of usage examples for android.content Intent putExtras
public @NonNull Intent putExtras(@NonNull Bundle extras)
From source file:com.boltarstudios.lok.GCMIntentService.java
@Override protected void onHandleIntent(Intent intent) { Log.i(Consts.TAG, "onHandleIntent"); Bundle extras = intent.getExtras();/* w w w .j a va 2s .c om*/ GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /* * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { Log.i(Consts.TAG, "onHandleIntent: message error"); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.i(Consts.TAG, "onHandleIntent: message deleted"); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { String subId = intent.getStringExtra(GCM_KEY_SUBID); Log.i(Consts.TAG, "onHandleIntent: subId: " + subId); String[] tokens = subId.split(":"); String typeId = tokens[1]; // dispatch message if (GCM_TYPEID_QUERY.equals(typeId)) { Intent messageIntent = new Intent(BROADCAST_ON_MESSAGE); messageIntent.putExtras(intent); messageIntent.putExtra("token", tokens[2]); Log.i(Consts.TAG, "onHandleIntent: tokens: " + tokens[0] + ", " + tokens[1] + ", " + tokens[2] + ":end:"); LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent); } } } // Release the wake lock provided by the WakefulBroadcastReceiver. Log.i("wakeful", "completeWakefulIntent"); GCMBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.deliciousdroid.fragment.MainSearchResultsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); base = (FragmentBaseActivity) getActivity(); base.setTitle(R.string.main_search_results_title); String[] MENU_ITEMS = new String[] { getString(R.string.search_results_bookmark), getString(R.string.search_results_tag), getString(R.string.search_results_global_tag) }; setListAdapter(new ArrayAdapter<String>(base, R.layout.main_view, MENU_ITEMS)); final Intent intent = base.getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { if (intent.hasExtra(SearchManager.QUERY)) { Intent i = new Intent(base, MainSearchResultsFragment.class); i.putExtras(intent.getExtras()); startActivity(i);/*from ww w . j a v a 2 s. co m*/ base.finish(); } else { base.onSearchRequested(); } } else if (Intent.ACTION_VIEW.equals(intent.getAction())) { Uri data = intent.getData(); String path = null; String tagname = null; if (data != null) { path = data.getPath(); tagname = data.getQueryParameter("tagname"); } if (data.getScheme() == null || !data.getScheme().equals("content")) { Intent i = new Intent(Intent.ACTION_VIEW, data); startActivity(i); base.finish(); } else if (path.contains("bookmarks") && TextUtils.isDigitsOnly(data.getLastPathSegment())) { Intent viewBookmark = new Intent(base, ViewBookmark.class); viewBookmark.setData(data); Log.d("View Bookmark Uri", data.toString()); startActivity(viewBookmark); base.finish(); } else if (tagname != null) { Intent viewTags = new Intent(base, BrowseBookmarks.class); viewTags.setData(data); Log.d("View Tags Uri", data.toString()); startActivity(viewTags); base.finish(); } } ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position == 0) { searchActionListener.onBookmarkSearch(); } else if (position == 1) { searchActionListener.onTagSearch(); } else if (position == 2) { searchActionListener.onGlobalTagSearch(); } } }); }
From source file:com.dwdesign.tweetings.activity.SetColorActivity.java
private void finishSelecting(final int color) { final Intent intent = new Intent(); final Bundle bundle = new Bundle(); bundle.putInt(Accounts.USER_COLOR, color); intent.putExtras(bundle); setResult(RESULT_OK, intent);//from ww w . j a va2 s . c o m finish(); }
From source file:com.example.pavle92.riddlequizapp.ARSimple.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 9890) { if (resultCode == Activity.RESULT_OK) { Bundle b = data.getExtras(); b.putString("ridle", ridle); b.putString("hint", hint); b.putString("solution", solution); Intent result = new Intent(); result.putExtras(b); setResult(Activity.RESULT_OK, result); finish();//from ww w . ja v a 2 s .c om } } }
From source file:edu.cwru.apo.APO.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // removes title bar on app, making image full screen requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.splash_screen); // load keys if they exist Auth.loadKeys(getSharedPreferences(APO.PREF_FILE_NAME, MODE_PRIVATE)); API api = new API(this); if (!api.callMethod(Methods.checkCredentials, this, (String[]) null)) { Intent loginIntent = new Intent(APO.this, Login.class); Bundle extras = new Bundle(); extras.putString("msg", "No saved credentials"); loginIntent.putExtras(extras); APO.this.startActivity(loginIntent); finish();//www .j a v a 2s . c o m } }
From source file:com.android.viewflow.ImageAdapter.java
public void GetImage(int position) { Intent intent = new Intent(mContext, DetailActivity.class); Bundle bundle = new Bundle(); bundle.putInt("image_id", images[position % images.length]); intent.putExtras(bundle); mContext.startActivity(intent);/*w w w . j a v a2 s .c o m*/ }
From source file:ch.hesso.master.sweetcity.activity.tag.TagSelectionActivity.java
@Override public void onClick(View v) { SparseBooleanArray checked = listView.getCheckedItemPositions(); ArrayList<Integer> selectedItems = new ArrayList<Integer>(); for (int i = 0; i < checked.size(); i++) { int position = checked.keyAt(i); if (checked.valueAt(i)) { selectedItems.add(CurrentTagList.getInstance().getPosition(adapter.getItem(position))); }// w ww .j a va2 s .c om } // Return tag selection list to the parent activity Intent resultIntent = new Intent(); Bundle bundle = new Bundle(); bundle.putIntegerArrayList("selectedItems", selectedItems); resultIntent.putExtras(bundle); setResult(Activity.RESULT_OK, resultIntent); finish(); }
From source file:ca.ualberta.cmput301.as1.czervos_notes.AddCounterActivity.java
/** * Creates a counter using the name input by the user and bundles the * counter to send back to the main activity (CounterListActivity). * @param view//from ww w.jav a 2 s .c o m */ public void createCounter(View view) { CounterModel newCounter; EditText editText = (EditText) findViewById(R.id.enter_counter_name); // Retrieves EditText's text input and converts to a string String counterName = editText.getText().toString(); newCounter = new CounterModel(counterName); Intent intent = new Intent(this, CounterListActivity.class); Bundle bundle = new Bundle(); // Bundles newly created counter bundle.putSerializable("newCounter", newCounter); intent.putExtras(bundle); startActivity(intent); }
From source file:com.umeng.community.example.CommunityApplication.java
@Override public void onCreate() { super.onCreate(); PlatformConfig.setWeixin("wx96110a1e3af63a39", "c60e3d3ff109a5d17013df272df99199"); //RENREN????? //?//from ww w.ja v a2 s.c o m PlatformConfig.setSinaWeibo("275392174", "d96fb6b323c60a42ed9f74bfab1b4f7a"); PlatformConfig.setQQZone("1104606393", "X4BAsJAVKtkDQ1zQ"); PushAgent.getInstance(this).setDebugMode(true); PushAgent.getInstance(this).setMessageHandler(new UmengMessageHandler() { @Override public void dealWithNotificationMessage(Context arg0, UMessage msg) { // ,???? super.dealWithNotificationMessage(arg0, msg); Log.e("", "### ???"); } }); PushAgent.getInstance(this).setNotificationClickHandler(new UHandler() { @Override public void handleMessage(Context context, UMessage uMessage) { com.umeng.comm.core.utils.Log.d("notifi", "getting message"); try { JSONObject jsonObject = uMessage.getRaw(); String feedid = ""; if (jsonObject != null) { com.umeng.comm.core.utils.Log.d("json", jsonObject.toString()); JSONObject extra = uMessage.getRaw().optJSONObject("extra"); feedid = extra.optString(Constants.FEED_ID); } Class myclass = Class.forName(uMessage.activity); Intent intent = new Intent(context, myclass); Bundle bundle = new Bundle(); bundle.putString(Constants.FEED_ID, feedid); intent.putExtras(bundle); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } catch (Exception e) { com.umeng.comm.core.utils.Log.d("class", e.getMessage()); } } }); }
From source file:com.example.firstapp.AbstractGetNameTask.java
/** * Contacts the user info server to get the profile of the user and extracts * the first name of the user from the profile. In order to authenticate * with the user info server the method first fetches an access token from * Google Play services./*from ww w. java 2 s . com*/ * @return * @return * * @throws IOException * if communication with user info server failed. * @throws JSONException * if the response from the server could not be parsed. */ private void fetchNameFromProfileServer() throws IOException, JSONException { String token = fetchToken(); URL url = new URL("https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + token); HttpURLConnection con = (HttpURLConnection) url.openConnection(); int sc = con.getResponseCode(); if (sc == 200) { InputStream is = con.getInputStream(); GOOGLE_USER_DATA = readResponse(is); is.close(); Intent intent = new Intent(mActivity, HomeActivity.class); Bundle b = new Bundle(); b.putSerializable("object", ob); intent.putExtras(b); intent.putExtra("email_id", mEmail); mActivity.startActivity(intent); mActivity.finish(); return; } else if (sc == 401) { GoogleAuthUtil.invalidateToken(mActivity, token); onError("Server auth error, please try again.", null); //Toast.makeText(mActivity, "Please try again", Toast.LENGTH_SHORT).show(); //mActivity.finish(); return; } else { onError("Server returned the following error code: " + sc, null); return; } }