List of usage examples for android.content Intent toString
@Override
public String toString()
From source file:kr.wdream.ui.ChatActivity.java
@Override public void onActivityResultFragment(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { if (requestCode == 0) { PhotoViewer.getInstance().setParentActivity(getParentActivity()); final ArrayList<Object> arrayList = new ArrayList<>(); int orientation = 0; try { ExifInterface ei = new ExifInterface(currentPicturePath); int exif = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (exif) { case ExifInterface.ORIENTATION_ROTATE_90: orientation = 90;//from ww w . j a v a2 s .c om break; case ExifInterface.ORIENTATION_ROTATE_180: orientation = 180; break; case ExifInterface.ORIENTATION_ROTATE_270: orientation = 270; break; } } catch (Exception e) { FileLog.e("tmessages", e); } arrayList.add(new MediaController.PhotoEntry(0, 0, 0, currentPicturePath, orientation, false)); PhotoViewer.getInstance().openPhotoForSelect(arrayList, 0, 2, new PhotoViewer.EmptyPhotoViewerProvider() { @Override public void sendButtonPressed(int index) { sendMedia((MediaController.PhotoEntry) arrayList.get(0), false); } }, this); AndroidUtilities.addMediaToGallery(currentPicturePath); currentPicturePath = null; } else if (requestCode == 1) { if (data == null || data.getData() == null) { showAttachmentError(); return; } Uri uri = data.getData(); if (uri.toString().contains("video")) { String videoPath = null; try { videoPath = AndroidUtilities.getPath(uri); } catch (Exception e) { FileLog.e("tmessages", e); } if (videoPath == null) { showAttachmentError(); } if (Build.VERSION.SDK_INT >= 16) { if (paused) { startVideoEdit = videoPath; } else { openVideoEditor(videoPath, false, false); } } else { SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id, replyingMessageObject, null); } } else { SendMessagesHelper.prepareSendingPhoto(null, uri, dialog_id, replyingMessageObject, null, null); } showReplyPanel(false, null, null, null, false, true); DraftQuery.cleanDraft(dialog_id, true); } else if (requestCode == 2) { String videoPath = null; FileLog.d("tmessages", "pic path " + currentPicturePath); if (data != null && currentPicturePath != null) { if (new File(currentPicturePath).exists()) { data = null; } } if (data != null) { Uri uri = data.getData(); if (uri != null) { FileLog.d("tmessages", "video record uri " + uri.toString()); videoPath = AndroidUtilities.getPath(uri); FileLog.d("tmessages", "resolved path = " + videoPath); if (!(new File(videoPath).exists())) { videoPath = currentPicturePath; } } else { videoPath = currentPicturePath; } AndroidUtilities.addMediaToGallery(currentPicturePath); currentPicturePath = null; } if (videoPath == null && currentPicturePath != null) { File f = new File(currentPicturePath); if (f.exists()) { videoPath = currentPicturePath; } currentPicturePath = null; } if (Build.VERSION.SDK_INT >= 16) { if (paused) { startVideoEdit = videoPath; } else { openVideoEditor(videoPath, false, false); } } else { SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id, replyingMessageObject, null); showReplyPanel(false, null, null, null, false, true); DraftQuery.cleanDraft(dialog_id, true); } } else if (requestCode == 21) { if (data == null || data.getData() == null) { showAttachmentError(); return; } Uri uri = data.getData(); String extractUriFrom = uri.toString(); if (extractUriFrom.contains("com.google.android.apps.photos.contentprovider")) { try { String firstExtraction = extractUriFrom.split("/1/")[1]; int index = firstExtraction.indexOf("/ACTUAL"); if (index != -1) { firstExtraction = firstExtraction.substring(0, index); String secondExtraction = URLDecoder.decode(firstExtraction, "UTF-8"); uri = Uri.parse(secondExtraction); } } catch (Exception e) { FileLog.e("tmessages", e); } } String tempPath = AndroidUtilities.getPath(uri); String originalPath = tempPath; if (tempPath == null) { originalPath = data.toString(); tempPath = MediaController.copyFileToCache(data.getData(), "file"); } if (tempPath == null) { showAttachmentError(); return; } SendMessagesHelper.prepareSendingDocument(tempPath, originalPath, null, null, dialog_id, replyingMessageObject); showReplyPanel(false, null, null, null, false, true); DraftQuery.cleanDraft(dialog_id, true); } else if (requestCode == 31) { if (data == null || data.getData() == null) { showAttachmentError(); return; } Uri uri = data.getData(); Cursor c = null; try { c = getParentActivity().getContentResolver().query(uri, new String[] { ContactsContract.Data.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER }, null, null, null); if (c != null) { boolean sent = false; while (c.moveToNext()) { sent = true; String name = c.getString(0); String number = c.getString(1); TLRPC.User user = new TLRPC.User(); user.first_name = name; user.last_name = ""; user.phone = number; SendMessagesHelper.getInstance().sendMessage(user, dialog_id, replyingMessageObject, null, null); } if (sent) { showReplyPanel(false, null, null, null, false, true); DraftQuery.cleanDraft(dialog_id, true); } } } finally { try { if (c != null && !c.isClosed()) { c.close(); } } catch (Exception e) { FileLog.e("tmessages", e); } } } } }
From source file:com.zoffcc.applications.zanavi.Navit.java
protected void onNewIntent(Intent intent) { super.onNewIntent(intent); try {//w w w .j av a 2 s .co m System.out.println("XXIIXX(2):111"); String mid_str = intent.getExtras().getString("com.zoffcc.applications.zanavi.mid"); System.out.println("XXIIXX(2):111a:mid_str=" + mid_str); if (mid_str != null) { if (mid_str.equals("201:UPDATE-APP")) { // a new ZANavi version is available, show something to the user here ------------------- // a new ZANavi version is available, show something to the user here ------------------- // a new ZANavi version is available, show something to the user here ------------------- // a new ZANavi version is available, show something to the user here ------------------- // a new ZANavi version is available, show something to the user here ------------------- // a new ZANavi version is available, show something to the user here ------------------- } else if (mid_str.startsWith("202:UPDATE-MAP:")) { // System.out.println("need to update1:" + mid_str); // System.out.println("need to update2:" + mid_str.substring(15)); auto_start_update_map(mid_str.substring(15)); } } System.out.println("XXIIXX(2):111b:mid_str=" + mid_str); } catch (Exception e) { e.printStackTrace(); System.out.println("XXIIXX(2):111:EEEE"); } // ---- Intent dump ---- // ---- Intent dump ---- // ---- Intent dump ---- // ---- Intent dump ---- try { System.out.println("XXIIXX(2):" + intent); Bundle bundle77 = intent.getExtras(); System.out.println("XXIIXX(2):" + intent_flags_to_string(intent.getFlags())); if (bundle77 == null) { System.out.println("XXIIXX(2):" + "null"); } else { for (String key : bundle77.keySet()) { Object value = bundle77.get(key); System.out.println("XXIIXX(2):" + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName())); } } } catch (Exception ee22) { String exst = Log.getStackTraceString(ee22); System.out.println("XXIIXX(2):ERR:" + exst); } // ---- Intent dump ---- // ---- Intent dump ---- // ---- Intent dump ---- // ---- Intent dump ---- Log.e("Navit", "3:**1**A " + intent.getAction()); Log.e("Navit", "3:**1**D " + intent.getDataString()); Log.e("Navit", "3:**1**S " + intent.toString()); try { Log.e("Navit", "3:**1**S " + intent.getExtras().describeContents()); } catch (Exception ee3) { } // if (Navit.startup_intent == null) { try { // make a copy of the given intent object // Navit.startup_intent = intent.cloneFilter(); Navit.startup_intent = intent; Log.e("Navit", "3a:**1**001"); Bundle extras2 = intent.getExtras(); Log.e("Navit", "3a:**1**002"); try { Navit.startup_intent.putExtras(extras2); Log.e("Navit", "3a:**1**003"); } catch (Exception e4) { if (startup_intent.getDataString() != null) { // we have a "geo:" thingy intent, use it // or "gpx file" Log.e("Navit", "3c:**1**A " + startup_intent.getAction()); Log.e("Navit", "3c:**1**D " + startup_intent.getDataString()); Log.e("Navit", "3c:**1**S " + startup_intent.toString()); } else { Log.e("Navit", "3X:**1**X "); Navit.startup_intent = null; } // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target! Navit.startup_intent_timestamp = System.currentTimeMillis(); return; } // Intent { act=android.intent.action.VIEW // cat=[android.intent.category.DEFAULT] // dat=file:///mnt/sdcard/zanavi_pos_recording_347834278.gpx // cmp=com.zoffcc.applications.zanavi/.Navit } // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target! Navit.startup_intent_timestamp = System.currentTimeMillis(); Log.e("Navit", "3a:**1**A " + startup_intent.getAction()); Log.e("Navit", "3a:**1**D " + startup_intent.getDataString()); Log.e("Navit", "3a:**1**S " + startup_intent.toString()); if (extras2 != null) { long l = extras2.getLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type"); // System.out.println("DH:a007 l=" + l); if (l != 0L) { if (l == Navit.NAVIT_START_INTENT_DRIVE_HOME) { // Log.e("Navit", "2:**1** started via drive home"); // we have been called from "drive home" widget // drive home // check if we have a home location int home_id = find_home_point(); if (home_id != -1) { Message msg7 = progress_handler.obtainMessage(); Bundle b7 = new Bundle(); msg7.what = 2; // long Toast message b7.putString("text", Navit.get_text("driving to Home Location")); //TRANS msg7.setData(b7); progress_handler.sendMessage(msg7); // clear any previous destinations Message msg2 = new Message(); Bundle b2 = new Bundle(); b2.putInt("Callback", 7); msg2.setData(b2); NavitGraphics.callback_handler.sendMessage(msg2); // set position to middle of screen ----------------------- // set position to middle of screen ----------------------- // set position to middle of screen ----------------------- // Message msg67 = new Message(); // Bundle b67 = new Bundle(); // b67.putInt("Callback", 51); // b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2)); // b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2)); // msg67.setData(b67); // N_NavitGraphics.callback_handler.sendMessage(msg67); // set position to middle of screen ----------------------- // set position to middle of screen ----------------------- // set position to middle of screen ----------------------- try { Thread.sleep(60); } catch (Exception e) { } route_wrapper(map_points.get(home_id).point_name, 0, 0, false, map_points.get(home_id).lat, map_points.get(home_id).lon, true); // Navit.destination_set(); // // // set destination to home location // String lat = String.valueOf(map_points.get(home_id).lat); // String lon = String.valueOf(map_points.get(home_id).lon); // String q = map_points.get(home_id).point_name; // // // System.out.println("lat=" + lat + " lon=" + lon + " name=" + q); // // Message msg55 = new Message(); // Bundle b55 = new Bundle(); // b55.putInt("Callback", 3); // b55.putString("lat", lat); // b55.putString("lon", lon); // b55.putString("q", q); // msg55.setData(b55); // NavitGraphics.callback_handler.sendMessage(msg55); final Thread zoom_to_route_001 = new Thread() { int wait = 1; int count = 0; int max_count = 60; @Override public void run() { while (wait == 1) { try { if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33)) { zoom_to_route(); wait = 0; } else { wait = 1; } count++; if (count > max_count) { wait = 0; } else { Thread.sleep(400); } } catch (Exception e) { } } } }; zoom_to_route_001.start(); // try // { // show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon)); // } // catch (Exception e2) // { // e2.printStackTrace(); // } try { Navit.follow_button_on(); } catch (Exception e2) { e2.printStackTrace(); } } else { // no home location set Message msg = progress_handler.obtainMessage(); Bundle b = new Bundle(); msg.what = 2; // long Toast message b.putString("text", Navit.get_text("No Home Location set")); //TRANS msg.setData(b); progress_handler.sendMessage(msg); } } } else { if (startup_intent.getDataString() != null) { // we have a "geo:" thingy intent, use it // or "gpx file" } else { Navit.startup_intent = null; } } } else { if (startup_intent.getDataString() != null) { // we have a "geo:" thingy intent, use it } else { Navit.startup_intent = null; } } } catch (Exception e99) { Navit.startup_intent = null; } } }