List of usage examples for android.content Intent getParcelableExtra
public <T extends Parcelable> T getParcelableExtra(String name)
From source file:bikebadger.RideFragment.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case MY_DATA_CHECK_CODE_REQUEST: // for testing //resultCode = TextToSpeech.Engine.CHECK_VOICE_DATA_FAIL; switch (resultCode) { case TextToSpeech.Engine.CHECK_VOICE_DATA_PASS: RideManager.mTTS = new TextToSpeech(mRideManager.mAppContext, this); //RideManager.mTTS = null; Log.v(Constants.APP.TAG, "TextToSpeech installed"); break; case TextToSpeech.Engine.CHECK_VOICE_DATA_BAD_DATA: case TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_DATA: case TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_VOLUME: case TextToSpeech.Engine.CHECK_VOICE_DATA_FAIL: Log.e(Constants.APP.TAG, "Got a failure. Text To Speech not available"); AlertDialog ad = new AlertDialog.Builder(getActivity()).create(); ad.setCancelable(false);//from w w w . j ava 2 s .co m ad.setTitle("Text To Speech Engine Not Found"); ad.setMessage( "There was a problem finding the Text To Speech Engine. Make sure it's install properly under Language and Input Settings."); ad.setButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); ad.show(); // missing data, install it //Log.v(Constants.APP.TAG, "Need language stuff: " + resultCode); //Intent installIntent = new Intent(); //installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); //startActivity(installIntent); break; } break; /* No longer used as it is deprecated. Use SimpleFileDialog instead even though it blocks. TODO - integrate a slick open file that includes DropBox and Drive library! case Constants.APP.FILE_CHOOSER_REQUEST_CODE: if (resultCode == getActivity().RESULT_OK) { if (data != null) { // Get the URI of the selected file final Uri uri = data.getData(); Log.i(Constants.APP.TAG, "Uri = " + uri.toString()); try { // Get the file path from the URI final String path = FileUtils.getPath(mRideManager.mAppContext, uri); //Toast.makeText(getActivity(), "File Selected: " + path, Toast.LENGTH_LONG).show(); OpenGPXFileOnNewThreadWithDialog(path); // if(isVisible()) // updateUI(); // update title bar file loaded } catch (Exception e) { Log.e("FileSelectorTestActivity", "File select error", e); } } } break; */ case Constants.APP.ACTION_WAYPOINT_REQUEST_CODE: if (resultCode == getActivity().RESULT_OK) { if (data != null) { final Location location = data.getParcelableExtra("location"); String command = data.getStringExtra("command"); final String arg = data.getStringExtra("argument"); mRideManager.AddNewWaypoint(command, arg, location); // enable the save menu mMenu.findItem(R.id.menu_item_gpx_save).setEnabled(true); } } break; case MY_MAP_CODE_REQUEST: if (resultCode == getActivity().RESULT_OK) { Log.d(Constants.APP.TAG, "Return from map"); } break; } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.dycody.android.idealnote.DetailFragment.java
@SuppressLint("NewApi") @Override//from ww w . j ava2 s .c o m public void onActivityResult(int requestCode, int resultCode, Intent intent) { // Fetch uri from activities, store into adapter and refresh adapter Attachment attachment; if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case TAKE_PHOTO: attachment = new Attachment(attachmentUri, Constants.MIME_TYPE_IMAGE); addAttachment(attachment); mAttachmentAdapter.notifyDataSetChanged(); mGridView.autoresize(); break; case TAKE_VIDEO: // Gingerbread doesn't allow custom folder so data are retrieved from intent if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) { attachment = new Attachment(attachmentUri, Constants.MIME_TYPE_VIDEO); } else { attachment = new Attachment(intent.getData(), Constants.MIME_TYPE_VIDEO); } addAttachment(attachment); mAttachmentAdapter.notifyDataSetChanged(); mGridView.autoresize(); break; case FILES: onActivityResultManageReceivedFiles(intent); break; case SET_PASSWORD: noteTmp.setPasswordChecked(true); lockUnlock(); break; case SKETCH: attachment = new Attachment(attachmentUri, Constants.MIME_TYPE_SKETCH); addAttachment(attachment); mAttachmentAdapter.notifyDataSetChanged(); mGridView.autoresize(); break; case CATEGORY: Toast.makeText(getActivity(), R.string.category_saved, Toast.LENGTH_SHORT).show(); //mainActivity.showMessage(R.string.category_saved, ONStyle.CONFIRM); Category category = intent.getParcelableExtra("category"); noteTmp.setCategory(category); setTagMarkerColor(category); break; case DETAIL: Toast.makeText(getActivity(), R.string.note_updated, Toast.LENGTH_SHORT).show(); //mainActivity.showMessage(R.string.note_updated, ONStyle.CONFIRM); break; default: Log.e(Constants.TAG, "Wrong element choosen: " + requestCode); } } }
From source file:com.cognizant.trumobi.PersonaLauncher.java
private static PersonaApplicationInfo infoFromShortcutIntent(Context context, Intent data) { Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); Bitmap bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON); Drawable icon = null;//from ww w . j a va 2 s . c o m boolean filtered = false; boolean customIcon = false; ShortcutIconResource iconResource = null; if (bitmap != null) { icon = new PersonaFastBitmapDrawable(PersonaUtilities.createBitmapThumbnail(bitmap, context)); filtered = true; customIcon = true; } else { Parcelable extra = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE); if (extra != null && extra instanceof ShortcutIconResource) { try { iconResource = (ShortcutIconResource) extra; final PackageManager packageManager = context.getPackageManager(); Resources resources = packageManager.getResourcesForApplication(iconResource.packageName); final int id = resources.getIdentifier(iconResource.resourceName, null, null); icon = resources.getDrawable(id); } catch (Exception e) { PersonaLog.w(LOG_TAG, "Could not load shortcut icon: " + extra); } } } if (icon == null) { icon = context.getPackageManager().getDefaultActivityIcon(); } final PersonaApplicationInfo info = new PersonaApplicationInfo(); info.icon = icon; info.filtered = filtered; info.title = name; info.intent = intent; info.customIcon = customIcon; info.iconResource = iconResource; return info; }
From source file:com.android.contacts.ContactSaveService.java
private void joinContacts(Intent intent) { long contactId1 = intent.getLongExtra(EXTRA_CONTACT_ID1, -1); long contactId2 = intent.getLongExtra(EXTRA_CONTACT_ID2, -1); // Load raw contact IDs for all raw contacts involved - currently edited and selected // in the join UIs. long rawContactIds[] = getRawContactIdsForAggregation(contactId1, contactId2); if (rawContactIds == null) { Log.e(TAG, "Invalid arguments for joinContacts request"); return;/*from w ww. j a v a 2 s. c o m*/ } ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>(); // For each pair of raw contacts, insert an aggregation exception for (int i = 0; i < rawContactIds.length; i++) { for (int j = 0; j < rawContactIds.length; j++) { if (i != j) { buildJoinContactDiff(operations, rawContactIds[i], rawContactIds[j]); } } } final ContentResolver resolver = getContentResolver(); // Use the name for contactId1 as the name for the newly aggregated contact. final Uri contactId1Uri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId1); final Uri entityUri = Uri.withAppendedPath(contactId1Uri, Contacts.Entity.CONTENT_DIRECTORY); Cursor c = resolver.query(entityUri, ContactEntityQuery.PROJECTION, ContactEntityQuery.SELECTION, null, null); if (c == null) { Log.e(TAG, "Unable to open Contacts DB cursor"); showToast(R.string.contactSavedErrorToast); return; } long dataIdToAddSuperPrimary = -1; try { if (c.moveToFirst()) { dataIdToAddSuperPrimary = c.getLong(ContactEntityQuery.DATA_ID); } } finally { c.close(); } // Mark the name from contactId1 IS_SUPER_PRIMARY to make sure that the contact // display name does not change as a result of the join. if (dataIdToAddSuperPrimary != -1) { Builder builder = ContentProviderOperation .newUpdate(ContentUris.withAppendedId(Data.CONTENT_URI, dataIdToAddSuperPrimary)); builder.withValue(Data.IS_SUPER_PRIMARY, 1); builder.withValue(Data.IS_PRIMARY, 1); operations.add(builder.build()); } // Apply all aggregation exceptions as one batch final boolean success = applyOperations(resolver, operations); final String name = queryNameOfLinkedContacts(new long[] { contactId1, contactId2 }); Intent callbackIntent = intent.getParcelableExtra(EXTRA_CALLBACK_INTENT); if (success && name != null) { if (TextUtils.isEmpty(name)) { showToast(R.string.contactsJoinedMessage); } else { showToast(R.string.contactsJoinedNamedMessage, name); } Uri uri = RawContacts.getContactLookupUri(resolver, ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactIds[0])); callbackIntent.setData(uri); LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(BROADCAST_LINK_COMPLETE)); } deliverCallback(callbackIntent); }
From source file:com.cognizant.trumobi.PersonaLauncher.java
static PersonaLiveFolderInfo addLiveFolder(Context context, Intent data, PersonaCellLayout.CellInfo cellInfo, boolean notify) { Intent baseIntent = data.getParcelableExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT); String name = data.getStringExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME); Drawable icon = null;//from w w w . ja v a 2s . c o m boolean filtered = false; Intent.ShortcutIconResource iconResource = null; Parcelable extra = data.getParcelableExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON); if (extra != null && extra instanceof Intent.ShortcutIconResource) { try { iconResource = (Intent.ShortcutIconResource) extra; final PackageManager packageManager = context.getPackageManager(); Resources resources = packageManager.getResourcesForApplication(iconResource.packageName); final int id = resources.getIdentifier(iconResource.resourceName, null, null); icon = resources.getDrawable(id); } catch (Exception e) { PersonaLog.w(LOG_TAG, "Could not load live folder icon: " + extra); } } if (icon == null) { icon = context.getResources().getDrawable(R.drawable.pr_ic_launcher_folder); } final PersonaLiveFolderInfo info = new PersonaLiveFolderInfo(); info.icon = icon; info.filtered = filtered; info.title = name; info.iconResource = iconResource; info.uri = data.getData(); info.baseIntent = baseIntent; info.displayMode = data.getIntExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE, LiveFolders.DISPLAY_MODE_GRID); PersonaLauncherModel.addItemToDatabase(context, info, PersonaLauncherSettings.Favorites.CONTAINER_DESKTOP, cellInfo.screen, cellInfo.cellX, cellInfo.cellY, notify); sModel.addFolder(info); return info; }
From source file:com.android.launcher3.Launcher.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public ItemInfo createAppDragInfo(Intent appLaunchIntent) { // Called from search suggestion UserHandleCompat user = null;/*from w w w. j a va 2 s. co m*/ if (Utilities.ATLEAST_LOLLIPOP) { UserHandle userHandle = appLaunchIntent.getParcelableExtra(Intent.EXTRA_USER); if (userHandle != null) { user = UserHandleCompat.fromUser(userHandle); } } return createAppDragInfo(appLaunchIntent, user); }
From source file:com.android.tv.MainActivity.java
private boolean handleIntent(Intent intent) { // Reset the closed caption settings when the activity is 1)created or 2) restarted. // And do not reset while TvView is playing. if (!mTvView.isPlaying()) { mCaptionSettings = new CaptionSettings(this); }//from www . jav a2s . c o m // Handle the passed key press, if any. Note that only the key codes that are currently // handled in the TV app will be handled via Intent. // TODO: Consider defining a separate intent filter as passing data of mime type // vnd.android.cursor.item/channel isn't really necessary here. int keyCode = intent.getIntExtra(Utils.EXTRA_KEY_KEYCODE, KeyEvent.KEYCODE_UNKNOWN); if (keyCode != KeyEvent.KEYCODE_UNKNOWN) { if (DEBUG) Log.d(TAG, "Got an intent with keycode: " + keyCode); KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, keyCode); onKeyUp(keyCode, event); return true; } mShouldTuneToTunerChannel = intent.getBooleanExtra(Utils.EXTRA_KEY_FROM_LAUNCHER, false); mInitChannelUri = null; String extraAction = intent.getStringExtra(Utils.EXTRA_KEY_ACTION); if (!TextUtils.isEmpty(extraAction)) { if (DEBUG) Log.d(TAG, "Got an extra action: " + extraAction); if (Utils.EXTRA_ACTION_SHOW_TV_INPUT.equals(extraAction)) { String lastWatchedChannelUri = Utils.getLastWatchedChannelUri(this); if (lastWatchedChannelUri != null) { mInitChannelUri = Uri.parse(lastWatchedChannelUri); } mShowSelectInputView = true; } } if (CommonFeatures.DVR.isEnabled(this) && BuildCompat.isAtLeastN()) { mRecordingUri = intent.getParcelableExtra(Utils.EXTRA_KEY_RECORDING_URI); if (mRecordingUri != null) { return true; } } // TODO: remove the checkState once N API is finalized. SoftPreconditions .checkState(TvInputManager.ACTION_SETUP_INPUTS.equals("android.media.tv.action.SETUP_INPUTS")); if (TvInputManager.ACTION_SETUP_INPUTS.equals(intent.getAction())) { runAfterAttachedToWindow(new Runnable() { @Override public void run() { mOverlayManager.showSetupFragment(); } }); } else if (Intent.ACTION_VIEW.equals(intent.getAction())) { Uri uri = intent.getData(); try { mSource = uri.getQueryParameter(Utils.PARAM_SOURCE); } catch (UnsupportedOperationException e) { // ignore this exception. } // When the URI points to the programs (directory, not an individual item), go to the // program guide. The intention here is to respond to // "content://android.media.tv/program", not "content://android.media.tv/program/XXX". // Later, we might want to add handling of individual programs too. if (Utils.isProgramsUri(uri)) { // The given data is a programs URI. Open the Program Guide. mShowProgramGuide = true; return true; } // In case the channel is given explicitly, use it. mInitChannelUri = uri; if (DEBUG) Log.d(TAG, "ACTION_VIEW with " + mInitChannelUri); if (Channels.CONTENT_URI.equals(mInitChannelUri)) { // Tune to default channel. mInitChannelUri = null; mShouldTuneToTunerChannel = true; return true; } if ((!Utils.isChannelUriForOneChannel(mInitChannelUri) && !Utils.isChannelUriForInput(mInitChannelUri))) { Log.w(TAG, "Malformed channel uri " + mInitChannelUri + " tuning to default instead"); mInitChannelUri = null; return true; } mTuneParams = intent.getExtras(); if (mTuneParams == null) { mTuneParams = new Bundle(); } if (Utils.isChannelUriForTunerInput(mInitChannelUri)) { long channelId = ContentUris.parseId(mInitChannelUri); mTuneParams.putLong(KEY_INIT_CHANNEL_ID, channelId); } else if (TvContract.isChannelUriForPassthroughInput(mInitChannelUri)) { // If mInitChannelUri is for a passthrough TV input. String inputId = mInitChannelUri.getPathSegments().get(1); TvInputInfo input = mTvInputManagerHelper.getTvInputInfo(inputId); if (input == null) { mInitChannelUri = null; Toast.makeText(this, R.string.msg_no_specific_input, Toast.LENGTH_SHORT).show(); return false; } else if (!input.isPassthroughInput()) { mInitChannelUri = null; Toast.makeText(this, R.string.msg_not_passthrough_input, Toast.LENGTH_SHORT).show(); return false; } } else if (mInitChannelUri != null) { // Handle the URI built by TvContract.buildChannelsUriForInput(). // TODO: Change hard-coded "input" to TvContract.PARAM_INPUT. String inputId = mInitChannelUri.getQueryParameter("input"); long channelId = Utils.getLastWatchedChannelIdForInput(this, inputId); if (channelId == Channel.INVALID_ID) { String[] projection = { Channels._ID }; try (Cursor cursor = getContentResolver().query(uri, projection, null, null, null)) { if (cursor != null && cursor.moveToNext()) { channelId = cursor.getLong(0); } } } if (channelId == Channel.INVALID_ID) { // Couldn't find any channel probably because the input hasn't been set up. // Try to set it up. mInitChannelUri = null; mInputToSetUp = mTvInputManagerHelper.getTvInputInfo(inputId); } else { mInitChannelUri = TvContract.buildChannelUri(channelId); mTuneParams.putLong(KEY_INIT_CHANNEL_ID, channelId); } } } return true; }
From source file:com.quwu.xinwo.release.Release_Activity.java
@SuppressWarnings("unchecked") protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case 20://from w w w. j a va 2 s .c om if (data != null) { if (requestCode == 20) { String sheng = data.getExtras().getString("sheng"); String shi = data.getExtras().getString("shi"); twolevel_id = data.getExtras().getString("id1"); three_id = data.getExtras().getString("id2"); classifyText.setText(sheng + " " + shi + " "); } } break; case CLASSIFY:// ? if (data != null) { String selection_sort = data.getExtras().getString("selection_sort");// Activity ?? classifyText.setText(selection_sort); } break; case KEYBOARD:// ? if (data != null) { list = (List<KeyBoardData>) data.getSerializableExtra("keyboard_data"); for (int i = 0; i < list.size(); i++) { selling_price = list.get(i).getSelling_price(); goods_value = list.get(i).getGoods_value(); original_price = list.get(i).getOriginal_price(); reserve_price = list.get(i).getReserve_price(); freight = list.get(i).getFreight(); check = list.get(i).isCheck(); } if (cordelesBox.isChecked() == true) { if (selling_price != null) { selling_priceEd.setText(selling_price); } } else if (auctionBox.isChecked() == true) { if (reserve_price != null) { auction_retainPriceEd.setText(reserve_price); } } else if (rent_outBox.isChecked() == true) { if (goods_value != null && freight != null) { rent_out_valueEd.setText(goods_value); if (check == true) { rent_out_freightEd.setText("0"); } else { rent_out_freightEd.setText(freight); } } } } break; case 10:// if (data != null) { for (int i = 0; i < MyAdapter.mSelectedImage.size(); i++) { photolist.add((String) data.getExtras().get(String.valueOf(i))); } } break; case 2017:// ? Log.e("onActivityResult", "?"); cropHelper.getDataFromCamera(data); break; case 2108: if (data != null && data.getParcelableExtra("data") != null) { for (int i = 0; i < times.size(); i++) { File f = new File( OSUtils.getSdCardDirectory(getApplicationContext()) + times.get(i) + "head1.png"); if (f.exists()) { camearlist.add( OSUtils.getSdCardDirectory(getApplicationContext()) + times.get(i) + "head1.png"); } } for (int k = 0; k < camearlist.size() - 1; k++) { for (int j = camearlist.size() - 1; j > k; j--) { if (camearlist.get(k).equals(camearlist.get(j))) { camearlist.remove(j); } } } for (int i = 0; i < camearlist.size(); i++) { photolist.add(camearlist.get(i)); } } break; case CameraUtils.RequestCode.FLAG_REQUEST_CAMERA_VIDEO:// if (data != null) { photolist.add(CameraUtils.CAMERA_VIDEO); } break; default: break; } for (int j = 0; j < photolist.size(); j++) { if (photolist.get(j).equals("drawable://" + R.drawable.fb_icn_carema)) { photolist.remove(j); } if (photolist.get(j).equals("drawable://" + R.drawable.fb_icn_video)) { photolist.remove(j); } } photolist.add("drawable://" + R.drawable.fb_icn_carema); photolist.add("drawable://" + R.drawable.fb_icn_video); for (int k = 0; k < photolist.size() - 1; k++) { for (int j = photolist.size() - 1; j > k; j--) { if (photolist.get(k).equals(photolist.get(j))) { photolist.remove(j); } } } adapter = new Release_GridViewAdapter(photolist, this, Release_Activity.this, times); gridView.setAdapter(adapter); gridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (photolist.get(position).equals("drawable://" + R.drawable.fb_icn_carema)) { int j = 0; for (int i = 0; i < photolist.size(); i++) { if (photolist.get(i).equals(CameraUtils.CAMERA_VIDEO)) { j++; } } if (j == 1) { if (photolist.size() < 13) { Date dt = new Date(); time = dt.getTime(); times.add(time); cropHelper = new CropHelper(Release_Activity.this, OSUtils.getSdCardDirectory(getApplicationContext()) + time + "head1.png"); mTempPhotoPath = OSUtils.getSdCardDirectory(getApplicationContext()) + time + "head1.png"; Release_Photo_Pop pop = new Release_Photo_Pop(Release_Activity.this, cropHelper, mTempPhotoPath); pop.showPopupWindow(gridView); } else { Toast.makeText(getApplicationContext(), "??~", 10).show(); } } else { if (photolist.size() < 12) { Date dt = new Date(); time = dt.getTime(); times.add(time); cropHelper = new CropHelper(Release_Activity.this, OSUtils.getSdCardDirectory(getApplicationContext()) + time + "head1.png"); mTempPhotoPath = OSUtils.getSdCardDirectory(getApplicationContext()) + time + "head1.png"; Release_Photo_Pop pop = new Release_Photo_Pop(Release_Activity.this, cropHelper, mTempPhotoPath); pop.showPopupWindow(gridView); } else { Toast.makeText(getApplicationContext(), "??~", 10).show(); } } } else if (photolist.get(position).equals("drawable://" + R.drawable.fb_icn_video)) { int j = 0; for (int i = 0; i < photolist.size(); i++) { if (photolist.get(i).equals(CameraUtils.CAMERA_VIDEO)) { j++; } } if (j != 1) { CameraUtils.openCameraForVideo(Release_Activity.this); } else { Toast.makeText(getApplicationContext(), "?~", 10).show(); } } else if (photolist.get(position).equals(CameraUtils.CAMERA_VIDEO)) {// ? Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); // ? Uri data = Uri.parse("file:///" + CameraUtils.CAMERA_VIDEO); // ??? intent.setDataAndType(data, "video/mp4"); // ? startActivity(intent); } } }); adapter.notifyDataSetChanged(); }
From source file:com.klinker.android.launcher.launcher3.Launcher.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public ItemInfo createAppDragInfo(Intent appLaunchIntent) { // Called from search suggestion UserHandleCompat user = null;/* w w w . j a v a2 s .c om*/ if (Utilities.isLmpOrAbove()) { UserHandle userHandle = appLaunchIntent.getParcelableExtra(Intent.EXTRA_USER); if (userHandle != null) { user = UserHandleCompat.fromUser(userHandle); } } return createAppDragInfo(appLaunchIntent, user); }
From source file:edu.cmu.mpcs.dashboard.TagViewer.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.tag_viewer); mNfcAdapter = NfcAdapter.getDefaultAdapter(this); Intent intent = this.getIntent(); writeContent = intent.getStringExtra("writeContent"); mLoginButton = new LoginButton(getApplicationContext()); // if(flag == true) Log.d("TAG_VIEWER", "writeConent:" + writeContent); // setContentView(R.layout.tag_viewer); mNfcPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); // mTagContent = (LinearLayout) findViewById(R.id.list); // mTitle = (TextView) findViewById(R.id.title); Log.d("TAG_VIEWER", "Utility.mFacebook is " + Utility.mFacebook); if (Utility.mFacebook == null) { InitializeLogin = true;// w ww .j ava 2 s. com } // Create the Facebook Object using the app id. edu.cmu.mpcs.dashboard.Utility.mFacebook = new Facebook(APP_ID); // Instantiate the asynrunner object for asynchronous api calls. edu.cmu.mpcs.dashboard.Utility.mAsyncRunner = new AsyncFacebookRunner( edu.cmu.mpcs.dashboard.Utility.mFacebook); Log.d("TAG_VIEWER", "in oncreate in TagViewer is session valid?:" + Utility.mFacebook.isSessionValid()); mLoginButton.init(this, AUTHORIZE_ACTIVITY_RESULT_CODE, Utility.mFacebook, permissions); if (APP_ID == null) { Util.showAlert(this, "Warning", "Facebook Applicaton ID must be " + "specified before running this example: see FbAPIs.java"); return; } SessionStore.restore(Utility.mFacebook, this); SessionEvents.addAuthListener(new FbAPIsAuthListener()); SessionEvents.addLogoutListener(new FbAPIsLogoutListener()); // SessionEvents.r if (Utility.mFacebook.isSessionValid()) { requestUserData(); } // TODO do something about - dont call resolve intent by // default. if (writeContent == null && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) { Log.d("TAG_VIEWER", "in OnCreate Before reading"); loginIntent = intent; if (InitializeLogin) { /* * This is if we come to tag viewer without * having started dashboard activity */ mLoginButton.initializeFbLogin(); } else { /* This is we if read the tag while in dashboard! */ resolveIntent(intent); } // mLoginButton.performLogout(); } else { Log.d("TAG_VIEWER", "Before creating alert dialog"); builder = new AlertDialog.Builder(TagViewer.this); dialog = builder.create(); builder.setTitle("Touch tag to write").setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { Log.d("TAG_VIEWER", "On cancel called"); disableTagWriteMode(); } }).create(); dialog.setTitle("touch tag to write"); dialog.show(); dialog.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { // TODO Auto-generated method stub Log.d("TAG_VIEWER", "On dismiss called"); disableTagWriteMode(); } }); // builder.setCancelable(true); // builder.setOnCancelListener(new // DialogInterface.OnCancelListener() { // public void onCancel(DialogInterface dialog) { // Log.d("TAG_VIEWER","On cancel called"); // disableTagWriteMode(); // // } // }).create().show(); } // Tag writing mode if (writeContent != null && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) { Log.d("TAG_VIEWER", "in Oncreate Before writing"); Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); try { WriteToTag.write(detectedTag, writeContent); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } Log.d("TAG_VIEWER", "in on create, writing to tag"); } Log.d("TAG_VIEWER", "in create"); }