List of usage examples for android.content Intent toString
@Override
public String toString()
From source file:com.kuacm.expo2013.service.SyncService.java
@Override protected void onHandleIntent(Intent intent) { Log.d(TAG, "onHandleIntent(intent=" + intent.toString() + ")"); final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_STATUS_RECEIVER); if (receiver != null) receiver.send(STATUS_RUNNING, Bundle.EMPTY); final Context context = this; final SharedPreferences prefs = getSharedPreferences(Prefs.IOSCHED_SYNC, Context.MODE_PRIVATE); final int localVersion = prefs.getInt(Prefs.LOCAL_VERSION, VERSION_NONE); try {/* w w w . ja v a2s .c om*/ // Bulk of sync work, performed by executing several fetches from // local and online sources. final long startLocal = System.currentTimeMillis(); final boolean localParse = localVersion < VERSION_CURRENT; Log.d(TAG, "found localVersion=" + localVersion + " and VERSION_CURRENT=" + VERSION_CURRENT); if (localParse) { // Load static local data mLocalExecutor.execute(R.xml.blocks, new LocalBlocksHandler()); mLocalExecutor.execute(R.xml.rooms, new LocalRoomsHandler()); mLocalExecutor.execute(R.xml.tracks, new LocalTracksHandler()); mLocalExecutor.execute(R.xml.search_suggest, new LocalSearchSuggestHandler()); mLocalExecutor.execute(R.xml.sessions, new LocalSessionsHandler()); // Parse values from local cache first, since spreadsheet copy // or network might be down. mLocalExecutor.execute(context, "cache-sessions.xml", new RemoteSessionsHandler()); mLocalExecutor.execute(context, "cache-speakers.xml", new RemoteSpeakersHandler()); mLocalExecutor.execute(context, "cache-vendors.xml", new RemoteVendorsHandler()); // Save local parsed version prefs.edit().putInt(Prefs.LOCAL_VERSION, VERSION_CURRENT).commit(); } Log.d(TAG, "local sync took " + (System.currentTimeMillis() - startLocal) + "ms"); // Always hit remote spreadsheet for any updates final long startRemote = System.currentTimeMillis(); mRemoteExecutor.executeGet(WORKSHEETS_URL, new RemoteWorksheetsHandler(mRemoteExecutor)); Log.d(TAG, "remote sync took " + (System.currentTimeMillis() - startRemote) + "ms"); } catch (Exception e) { Log.e(TAG, "Problem while syncing", e); if (receiver != null) { // Pass back error to surface listener final Bundle bundle = new Bundle(); bundle.putString(Intent.EXTRA_TEXT, e.toString()); receiver.send(STATUS_ERROR, bundle); } } // Announce success to any surface listener Log.d(TAG, "sync finished"); if (receiver != null) receiver.send(STATUS_FINISHED, Bundle.EMPTY); }
From source file:com.google.android.apps.iosched2.service.SyncService.java
@Override protected void onHandleIntent(Intent intent) { Log.d(TAG, "onHandleIntent(intent=" + intent.toString() + ")"); final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_STATUS_RECEIVER); if (receiver != null) receiver.send(STATUS_RUNNING, Bundle.EMPTY); final Context context = this; final SharedPreferences prefs = getSharedPreferences(Prefs.SCHED_SYNC, Context.MODE_PRIVATE); final int localVersion = prefs.getInt(Prefs.LOCAL_VERSION, VERSION_NONE); try {//from w w w.ja v a 2s. c o m // Bulk of sync work, performed by executing several fetches from // local and online sources. final long startLocal = System.currentTimeMillis(); final boolean localParse = localVersion < VERSION_CURRENT; Log.d(TAG, "found localVersion=" + localVersion + " and VERSION_CURRENT=" + VERSION_CURRENT); if (localParse) { // Load static local data mLocalExecutor.execute(Setup.BLOCKS_XML, new LocalBlocksHandler()); mLocalExecutor.execute(Setup.ROOMS_XML, new LocalRoomsHandler()); // mLocalExecutor.execute(R.xml.blocks, new LocalBlocksHandler()); // mLocalExecutor.execute(R.xml.rooms, new LocalRoomsHandler()); mLocalExecutor.execute(R.xml.tracks, new LocalTracksHandler()); mLocalExecutor.execute(R.xml.search_suggest, new LocalSearchSuggestHandler()); mLocalExecutor.execute(R.xml.sessions, new LocalSessionsHandler()); // Parse values from local cache first, since spreadsheet copy // or network might be down. mLocalExecutor.execute(context, Setup.EVENT_PREFIX + "cache-sessions.xml", new RemoteSessionsHandler()); mLocalExecutor.execute(context, Setup.EVENT_PREFIX + "cache-speakers.xml", new RemoteSpeakersHandler()); if (Setup.FEATURE_VENDORS_ON) { mLocalExecutor.execute(context, Setup.EVENT_PREFIX + "cache-vendors.xml", new RemoteVendorsHandler()); } // Save local parsed version prefs.edit().putInt(Prefs.LOCAL_VERSION, VERSION_CURRENT).commit(); } Log.d(TAG, "local sync took " + (System.currentTimeMillis() - startLocal) + "ms"); // Always hit remote spreadsheet for any updates final long startRemote = System.currentTimeMillis(); mRemoteExecutor.executeGet(WORKSHEETS_URL, new RemoteWorksheetsHandler(mRemoteExecutor)); Log.d(TAG, "remote sync took " + (System.currentTimeMillis() - startRemote) + "ms"); } catch (Exception e) { Log.e(TAG, "Problem while syncing", e); if (receiver != null) { // Pass back error to surface listener final Bundle bundle = new Bundle(); bundle.putString(Intent.EXTRA_TEXT, e.toString()); receiver.send(STATUS_ERROR, bundle); } } // Announce success to any surface listener Log.d(TAG, "sync finished"); if (receiver != null) receiver.send(STATUS_FINISHED, Bundle.EMPTY); }
From source file:com.artech.android.gcm.GcmIntentService.java
public void onMessageReceive(Intent intent) { Log.d("onMessage", intent.toString()); //$NON-NLS-1$ Log.w("GCM", "Message Receiver called"); //$NON-NLS-1$ //$NON-NLS-2$ Bundle extras = intent.getExtras();/*w w w.ja va 2 s . c o m*/ if (extras != null) { // read message data String payload = null; String action = null; String parameters = null; String executionTime = null; String from = null; String cmd = null; final String jsonData = extras.getString("data"); //$NON-NLS-1$ boolean readFromData = false; if (jsonData != null) { //Special read from Parse data JSONObject jsonObject; try { jsonObject = new JSONObject(jsonData); payload = getJsonString(jsonObject, "alert"); //$NON-NLS-1$ action = getJsonString(jsonObject, "action"); //$NON-NLS-1$ parameters = getJsonString(jsonObject, "parameters"); //$NON-NLS-1$ executionTime = getJsonString(jsonObject, "executiontime"); //$NON-NLS-1$ from = getJsonString(jsonObject, "from"); //$NON-NLS-1$ cmd = getJsonString(jsonObject, "CMD"); //$NON-NLS-1$ readFromData = true; } catch (JSONException e) { e.printStackTrace(); } } //Standard read from intent. if (jsonData == null || !readFromData) { payload = extras.getString("payload"); //$NON-NLS-1$ action = extras.getString("action"); //$NON-NLS-1$ parameters = extras.getString("parameters"); //$NON-NLS-1$ executionTime = extras.getString("executiontime"); //$NON-NLS-1$ from = extras.getString("from"); //$NON-NLS-1$ cmd = extras.getString("CMD"); //$NON-NLS-1$ } //show some log about payload. Log.d("GCM", "dmControl: payload = " + payload + " action = " + action); //$NON-NLS-1$ //$NON-NLS-2$ // Filter gcm new api message, filter using from? : // http://stackoverflow.com/questions/30479424/weird-push-message-received-on-app-start if (Services.Strings.hasValue(from) && Services.Strings.hasValue(cmd) && !Services.Strings.hasValue(action) && !Services.Strings.hasValue(payload) && !Services.Strings.hasValue(parameters)) { Log.d("GCM", "ignore GCM messsage from: = " + from); //$NON-NLS-1$ //$NON-NLS-2$ return; } // Silent if not message and has action, only run this with the new notification API if (Strings.hasValue(action) && Strings.hasValue(executionTime) && !Strings.hasValue(payload) && executionTime.equalsIgnoreCase("1")) // 1= OnNotificationArrive callSilentAction(action, parameters); else createNotification(payload, action, parameters); } }
From source file:com.example.android.supportv4.app.SimpleJobIntentService.java
@Override protected void onHandleWork(Intent intent) { // We have received work to do. The system or framework is already // holding a wake lock for us at this point, so we can just go. Log.i("SimpleJobIntentService", "Executing work: " + intent); String label = intent.getStringExtra("label"); if (label == null) { label = intent.toString(); }/* w w w .j a v a 2s . c o m*/ toast("Executing: " + label); for (int i = 0; i < 5; i++) { Log.i("SimpleJobIntentService", "Running service " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(1000); } catch (InterruptedException e) { } } Log.i("SimpleJobIntentService", "Completed service @ " + SystemClock.elapsedRealtime()); }
From source file:com.hb.hkm.hypebeaststore.BaseStoreFront.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); try {//ww w .j av a 2s. c om Log.d(TAG, requestCode + requestCode + data.toString()); } catch (Exception e) { Log.d(TAG, "this error from result" + e.getMessage()); e.printStackTrace(); } }
From source file:mobisocial.bento.anyshare.ui.FeedItemListActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent ret) { if (requestCode == REQUEST_PICK) { if (resultCode == RESULT_OK) { Log.d(TAG, ret.toString()); Uri uri = ret.getData();//from w w w . j ava 2 s. c o m Intent intent = new Intent(this, PostActivity.class); intent.setAction(Intent.ACTION_SEND); String mimetype = getContentResolver().getType(uri); String ext = MimeTypeMap.getFileExtensionFromUrl(uri.toString()); MimeTypeMap mime = MimeTypeMap.getSingleton(); if (mimetype == null || mimetype.isEmpty()) { if (!ext.isEmpty()) { mimetype = mime.getMimeTypeFromExtension(ext); } } String fname = uri.getLastPathSegment(); if (ext.isEmpty()) { fname += "." + mime.getExtensionFromMimeType(mimetype); } intent.setType(mimetype); intent.putExtra(Intent.EXTRA_SUBJECT, fname); intent.putExtra(Intent.EXTRA_TEXT, ""); intent.putExtra(Intent.EXTRA_STREAM, uri); startActivityForResult(intent, HomeActivity.REQUEST_VIEW); } } super.onActivityResult(requestCode, resultCode, ret); }
From source file:com.heneryh.aquanotes.service.NightlyService.java
@Override protected void onHandleIntent(Intent intent) { Log.d(TAG, "onHandleIntent(intent=" + intent.toString() + ")"); /**/*from w ww.j av a 2s .c o m*/ * Using the intent, we can tell why we are running this service */ /** * Only start processing thread if not already running, if the thread was running it would * grab the queue items */ synchronized (sLock) { if (!sThreadRunning) { sThreadRunning = true; new NightlyThread().execute(); } } }
From source file:de.quist.app.errorreporter.ExceptionReportService.java
private void sendReport(Intent intent) throws UnsupportedEncodingException, NameNotFoundException { Log.v(TAG, "Got request to report error: " + intent.toString()); Uri server = getTargetUrl();/* w w w . j a v a 2s. com*/ boolean isManualReport = intent.getBooleanExtra(EXTRA_MANUAL_REPORT, false); boolean isReportOnFroyo = isReportOnFroyo(); boolean isFroyoOrAbove = isFroyoOrAbove(); if (isFroyoOrAbove && !isManualReport && !isReportOnFroyo) { // We don't send automatic reports on froyo or above Log.d(TAG, "Don't send automatic report on froyo"); return; } Set<String> fieldsToSend = getFieldsToSend(); String stacktrace = intent.getStringExtra(EXTRA_STACK_TRACE); String exception = intent.getStringExtra(EXTRA_EXCEPTION_CLASS); String message = intent.getStringExtra(EXTRA_MESSAGE); long availableMemory = intent.getLongExtra(EXTRA_AVAILABLE_MEMORY, -1l); long totalMemory = intent.getLongExtra(EXTRA_TOTAL_MEMORY, -1l); String dateTime = intent.getStringExtra(EXTRA_EXCEPTION_TIME); String threadName = intent.getStringExtra(EXTRA_THREAD_NAME); String extraMessage = intent.getStringExtra(EXTRA_EXTRA_MESSAGE); List<NameValuePair> params = new ArrayList<NameValuePair>(); addNameValuePair(params, fieldsToSend, "exStackTrace", stacktrace); addNameValuePair(params, fieldsToSend, "exClass", exception); addNameValuePair(params, fieldsToSend, "exDateTime", dateTime); addNameValuePair(params, fieldsToSend, "exMessage", message); addNameValuePair(params, fieldsToSend, "exThreadName", threadName); if (extraMessage != null) addNameValuePair(params, fieldsToSend, "extraMessage", extraMessage); if (availableMemory >= 0) addNameValuePair(params, fieldsToSend, "devAvailableMemory", availableMemory + ""); if (totalMemory >= 0) addNameValuePair(params, fieldsToSend, "devTotalMemory", totalMemory + ""); PackageManager pm = getPackageManager(); try { PackageInfo packageInfo = pm.getPackageInfo(getPackageName(), 0); addNameValuePair(params, fieldsToSend, "appVersionCode", packageInfo.versionCode + ""); addNameValuePair(params, fieldsToSend, "appVersionName", packageInfo.versionName); addNameValuePair(params, fieldsToSend, "appPackageName", packageInfo.packageName); } catch (NameNotFoundException e) { } addNameValuePair(params, fieldsToSend, "devModel", android.os.Build.MODEL); addNameValuePair(params, fieldsToSend, "devSdk", android.os.Build.VERSION.SDK); addNameValuePair(params, fieldsToSend, "devReleaseVersion", android.os.Build.VERSION.RELEASE); HttpClient httpClient = new DefaultHttpClient(); HttpPost post = new HttpPost(server.toString()); post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); Log.d(TAG, "Created post request"); try { httpClient.execute(post); Log.v(TAG, "Reported error: " + intent.toString()); } catch (ClientProtocolException e) { // Ignore this kind of error Log.e(TAG, "Error while sending an error report", e); } catch (SSLException e) { Log.e(TAG, "Error while sending an error report", e); } catch (IOException e) { if (e instanceof SocketException && e.getMessage().contains("Permission denied")) { Log.e(TAG, "You don't have internet permission", e); } else { int maximumRetryCount = getMaximumRetryCount(); int maximumExponent = getMaximumBackoffExponent(); // Retry at a later point in time AlarmManager alarmMgr = (AlarmManager) getSystemService(ALARM_SERVICE); int exponent = intent.getIntExtra(EXTRA_CURRENT_RETRY_COUNT, 0); intent.putExtra(EXTRA_CURRENT_RETRY_COUNT, exponent + 1); PendingIntent operation = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); if (exponent >= maximumRetryCount) { // Discard error Log.w(TAG, "Error report reached the maximum retry count and will be discarded.\nStacktrace:\n" + stacktrace); return; } if (exponent > maximumExponent) { exponent = maximumExponent; } long backoff = (1 << exponent) * 1000; // backoff in ms alarmMgr.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + backoff, operation); } } }
From source file:org.ohmage.mobility.activity.ActivityRecognitionIntentService.java
/** * Called when a new activity detection update is available. *//* w w w. j a v a2 s. com*/ @Override protected void onHandleIntent(final Intent intent) { // start a new thread to receive data to avoid stuck the IntentService which use only single thread new Thread(new Runnable() { @Override public void run() { Log.e(ActivityRecognitionIntentService.class.getSimpleName(), intent.toString()); // If the intent contains an update if (ActivityRecognitionResult.hasResult(intent)) { // Get the update ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent); // Write the result to the DSU writeResultToDsu(result); // Log the update Log.i(ActivityRecognitionIntentService.class.getSimpleName(), result.toString()); logActivityRecognitionResult(result); // Disable dynamicChangeLocationSampleRate to save battery // dynamicChangeLocationSampleRate(result); } } }).start(); }
From source file:edu.stanford.junction.sample.partyware.ImgurUploadService.java
/** * //from www . jav a 2 s . c o m * @return a map that contains objects with the following keys: * * delete - the url used to delete the uploaded image (null if * error). * * original - the url to the uploaded image (null if error) The map * is null if error */ private Map<String, String> handleSendIntent(final Intent intent) { Log.i(this.getClass().getName(), "in handleResponse()"); Log.d(this.getClass().getName(), intent.toString()); final Bundle extras = intent.getExtras(); try { //upload a new image if (Intent.ACTION_SEND.equals(intent.getAction()) && (extras != null) && extras.containsKey(Intent.EXTRA_STREAM)) { final Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM); if (uri != null) { Log.d(this.getClass().getName(), uri.toString()); imageLocation = uri; final String jsonOutput = readPictureDataAndUpload(uri); return parseJSONResponse(jsonOutput); } Log.e(this.getClass().getName(), "URI null"); } } catch (final Exception e) { Log.e(this.getClass().getName(), "Completely unexpected error", e); } return null; }