List of usage examples for android.util Log getStackTraceString
public static String getStackTraceString(Throwable tr)
From source file:com.determinato.feeddroid.parser.RssParser.java
/** * Returns indication of updated RSS feed icon. * @param id ID of channel/*from w ww .j av a2s . c o m*/ * @param iconUrl RSS channel icon URL * @return true if updated, false otherwise */ public boolean updateFavicon(long id, URL iconUrl) { InputStream in = null; OutputStream out = null; boolean r = false; Uri iconUri = FeedDroid.Channels.CONTENT_URI.buildUpon().appendPath(String.valueOf(id)).appendPath("icon") .build(); try { in = iconUrl.openStream(); out = mResolver.openOutputStream(iconUri); byte[] b = new byte[1024]; int n; while ((n = in.read(b)) != -1) out.write(b, 0, n); r = true; } catch (Exception e) { Log.d(TAG, Log.getStackTraceString(e)); } finally { try { if (in != null) in.close(); if (out != null) out.close(); } catch (IOException e) { } } return r; }
From source file:com.zhengde163.netguard.ActivityLog.java
@Override protected void onCreate(Bundle savedInstanceState) { // Util.setTheme(this); setTheme(R.style.AppThemeBlue);//ww w . java 2s. co m super.onCreate(savedInstanceState); setContentView(R.layout.logging); running = true; // Action bar View actionView = getLayoutInflater().inflate(R.layout.actionlog, null, false); // SwitchCompat swEnabled = (SwitchCompat) actionView.findViewById(R.id.swEnabled); ImageView ivEnabled = (ImageView) actionView.findViewById(R.id.ivEnabled); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setCustomView(actionView); getSupportActionBar().setTitle(R.string.menu_log); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Get settings final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); resolve = prefs.getBoolean("resolve", false); organization = prefs.getBoolean("organization", false); log = prefs.getBoolean("log", false); // Show disabled message // TextView tvDisabled = (TextView) findViewById(R.id.tvDisabled); // tvDisabled.setVisibility(log ? View.GONE : View.VISIBLE); final LinearLayout ly = (LinearLayout) findViewById(R.id.lldisable); ly.setVisibility(log ? View.GONE : View.VISIBLE); ImageView ivClose = (ImageView) findViewById(R.id.ivClose); ivClose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ly.setVisibility(View.GONE); } }); // Set enabled switch // swEnabled.setChecked(log); if (ivEnabled != null) { if (log) { ivEnabled.setImageResource(R.drawable.on); } else { ivEnabled.setImageResource(R.drawable.off); } ivEnabled.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { log = !log; boolean isChecked = log; prefs.edit().putBoolean("log", isChecked).apply(); } }); } // swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { // public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // prefs.edit().putBoolean("log", isChecked).apply(); // } // }); // Listen for preference changes prefs.registerOnSharedPreferenceChangeListener(this); lvLog = (ListView) findViewById(R.id.lvLog); boolean udp = prefs.getBoolean("proto_udp", true); boolean tcp = prefs.getBoolean("proto_tcp", true); boolean other = prefs.getBoolean("proto_other", true); boolean allowed = prefs.getBoolean("traffic_allowed", true); boolean blocked = prefs.getBoolean("traffic_blocked", true); adapter = new AdapterLog(this, DatabaseHelper.getInstance(this).getLog(udp, tcp, other, allowed, blocked), resolve, organization); adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(CharSequence constraint) { return DatabaseHelper.getInstance(ActivityLog.this).searchLog(constraint.toString()); } }); lvLog.setAdapter(adapter); try { vpn4 = InetAddress.getByName(prefs.getString("vpn4", "10.1.10.1")); vpn6 = InetAddress.getByName(prefs.getString("vpn6", "fd00:1:fd00:1:fd00:1:fd00:1")); } catch (UnknownHostException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } lvLog.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { PackageManager pm = getPackageManager(); Cursor cursor = (Cursor) adapter.getItem(position); long time = cursor.getLong(cursor.getColumnIndex("time")); int version = cursor.getInt(cursor.getColumnIndex("version")); int protocol = cursor.getInt(cursor.getColumnIndex("protocol")); final String saddr = cursor.getString(cursor.getColumnIndex("saddr")); final int sport = (cursor.isNull(cursor.getColumnIndex("sport")) ? -1 : cursor.getInt(cursor.getColumnIndex("sport"))); final String daddr = cursor.getString(cursor.getColumnIndex("daddr")); final int dport = (cursor.isNull(cursor.getColumnIndex("dport")) ? -1 : cursor.getInt(cursor.getColumnIndex("dport"))); final String dname = cursor.getString(cursor.getColumnIndex("dname")); final int uid = (cursor.isNull(cursor.getColumnIndex("uid")) ? -1 : cursor.getInt(cursor.getColumnIndex("uid"))); int allowed = (cursor.isNull(cursor.getColumnIndex("allowed")) ? -1 : cursor.getInt(cursor.getColumnIndex("allowed"))); // Get external address InetAddress addr = null; try { addr = InetAddress.getByName(daddr); } catch (UnknownHostException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } String ip; int port; if (addr.equals(vpn4) || addr.equals(vpn6)) { ip = saddr; port = sport; } else { ip = daddr; port = dport; } // Build popup menu PopupMenu popup = new PopupMenu(ActivityLog.this, findViewById(R.id.vwPopupAnchor)); popup.inflate(R.menu.log); // Application name if (uid >= 0) popup.getMenu().findItem(R.id.menu_application) .setTitle(TextUtils.join(", ", Util.getApplicationNames(uid, ActivityLog.this))); else popup.getMenu().removeItem(R.id.menu_application); // Destination IP popup.getMenu().findItem(R.id.menu_protocol) .setTitle(Util.getProtocolName(protocol, version, false)); // Whois final Intent lookupIP = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.tcpiputils.com/whois-lookup/" + ip)); if (pm.resolveActivity(lookupIP, 0) == null) popup.getMenu().removeItem(R.id.menu_whois); else popup.getMenu().findItem(R.id.menu_whois).setTitle(getString(R.string.title_log_whois, ip)); // Lookup port final Intent lookupPort = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.speedguide.net/port.php?port=" + port)); if (port <= 0 || pm.resolveActivity(lookupPort, 0) == null) popup.getMenu().removeItem(R.id.menu_port); else popup.getMenu().findItem(R.id.menu_port).setTitle(getString(R.string.title_log_port, port)); if (!prefs.getBoolean("filter", false)) { popup.getMenu().removeItem(R.id.menu_allow); popup.getMenu().removeItem(R.id.menu_block); } final Packet packet = new Packet(); packet.version = version; packet.protocol = protocol; packet.daddr = daddr; packet.dport = dport; packet.time = time; packet.uid = uid; packet.allowed = (allowed > 0); // Time popup.getMenu().findItem(R.id.menu_time) .setTitle(SimpleDateFormat.getDateTimeInstance().format(time)); // Handle click popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.menu_application: { Intent main = new Intent(ActivityLog.this, ActivityMain.class); main.putExtra(ActivityMain.EXTRA_SEARCH, Integer.toString(uid)); startActivity(main); return true; } case R.id.menu_whois: startActivity(lookupIP); return true; case R.id.menu_port: startActivity(lookupPort); return true; case R.id.menu_allow: DatabaseHelper.getInstance(ActivityLog.this).updateAccess(packet, dname, 0); ServiceSinkhole.reload("allow host", ActivityLog.this); Intent main = new Intent(ActivityLog.this, ActivityMain.class); main.putExtra(ActivityMain.EXTRA_SEARCH, Integer.toString(uid)); startActivity(main); return true; case R.id.menu_block: DatabaseHelper.getInstance(ActivityLog.this).updateAccess(packet, dname, 1); ServiceSinkhole.reload("block host", ActivityLog.this); Intent main1 = new Intent(ActivityLog.this, ActivityMain.class); main1.putExtra(ActivityMain.EXTRA_SEARCH, Integer.toString(uid)); startActivity(main1); return true; default: return false; } } }); // Show popup.show(); } }); live = true; }
From source file:com.dm.material.dashboard.candybar.activities.CandyBarSplashActivity.java
private void prepareCloudWallpapers(@NonNull Context context) { final String wallpaperUrl = getResources().getString(R.string.wallpaper_json); mPrepareCloudWallpapers = new AsyncTask<Void, Void, Boolean>() { @Override// w w w. j a va 2 s .c o m protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); if (WallpaperHelper.getWallpaperType(context) != WallpaperHelper.CLOUD_WALLPAPERS) return true; Database database = new Database(context); if (database.getWallpapersCount() > 0) return true; URL url = new URL(wallpaperUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setConnectTimeout(15000); if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { InputStream stream = connection.getInputStream(); WallpaperJSON wallpapersJSON = LoganSquare.parse(stream, WallpaperJSON.class); if (database.getWallpapersCount() > 0) database.deleteWallpapers(); database.addWallpapers(wallpapersJSON); } return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; } @Override protected void onPostExecute(Boolean aBoolean) { super.onPostExecute(aBoolean); mPrepareCloudWallpapers = null; } }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); }
From source file:com.nick.scalpel.core.opt.BeanFactory.java
@SuppressWarnings({ "unchecked", "TryWithIdenticalCatches" }) Object createBean(String clzName) { Class clz;//ww w. j av a 2 s. c om try { clz = Class.forName(clzName); } catch (ClassNotFoundException e) { logE("Error when create bean for:" + clzName + "\n" + Log.getStackTraceString(e)); return null; } // Find empty constructor. Constructor constructor = null; try { constructor = clz.getDeclaredConstructor(); } catch (NoSuchMethodException e) { logE("No empty constructor for:" + clzName); } if (constructor != null) { makeAccessible(constructor); try { return constructor.newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { logE("Error when create bean for:" + clzName + "\n" + Log.getStackTraceString(e)); } catch (InvocationTargetException e) { logE("Error when create bean for:" + clzName + "\n" + Log.getStackTraceString(e)); } } logD("Can not find empty Constructor for class:" + clzName); // Find Context constructor. try { constructor = clz.getDeclaredConstructor(Context.class); } catch (NoSuchMethodException e) { logE("No context-ed constructor for:" + clzName); } if (constructor != null) { makeAccessible(constructor); try { return constructor.newInstance(mContext); } catch (InstantiationException e) { logE("Error when create bean for:" + clzName + "\n" + Log.getStackTraceString(e)); } catch (IllegalAccessException e) { logE("Error when create bean for:" + clzName + "\n" + Log.getStackTraceString(e)); } catch (InvocationTargetException e) { logE("Error when create bean for:" + clzName + "\n" + Log.getStackTraceString(e)); } } logE("Failed to create bean for:" + clzName); return null; }
From source file:com.g_node.gca.schedule.ScheduleJSONParse.java
public void getScheduleJSONData() { try {/*from w w w.j a va 2 s .com*/ BufferedReader jsonReader = new BufferedReader(new InputStreamReader(jsonStream)); StringBuilder jsonBuilder = new StringBuilder(); for (String line = null; (line = jsonReader.readLine()) != null;) { jsonBuilder.append(line).append("\n"); } JSONTokener tokener = new JSONTokener(jsonBuilder.toString()); JSONArray jsonArray = new JSONArray(tokener); //totalPages = jsonArray.length(); for (int counter = 0; counter < jsonArray.length(); counter++) { // data[counter] = new ArrayList<ScheduleItem>(); JSONObject scheduleItemJsonObject = jsonArray.getJSONObject(counter); //get the event object - can be event, session or track if (scheduleItemJsonObject.has("start")) { // 'start' key is only in event String event_title = scheduleItemJsonObject.getString("title"); Log.i(LOG_TAG, "Basic Event - title: " + event_title); String event_subtitle = scheduleItemJsonObject.getString("subtitle"); Log.i(LOG_TAG, "Basic Event - subtitle: " + event_subtitle); String event_start_time = scheduleItemJsonObject.getString("start"); Log.i(LOG_TAG, "Basic Event - Start: " + event_start_time); String event_end_time = scheduleItemJsonObject.getString("end"); Log.i(LOG_TAG, "Basic Event - end : " + event_end_time); String event_location = scheduleItemJsonObject.getString("location"); Log.i(LOG_TAG, "Basic Event - Location: " + event_location); String event_date = scheduleItemJsonObject.getString("date"); Log.i(LOG_TAG, "Basic Event - date: " + event_date); String event_authors = scheduleItemJsonObject.getJSONArray("authors").toString() .replace("\"", "").replace("[", "").replace("]", ""); Log.i(LOG_TAG, "Basic Event - Authors: " + event_authors); String event_type = scheduleItemJsonObject.getString("type"); Log.i(LOG_TAG, "Basic Event - Type: " + event_type); String event_abstract = scheduleItemJsonObject.getString("abstract"); Log.i(LOG_TAG, "Basic Event - Abstract: " + event_abstract); //adding the event to events arraylist eventsRecordsArray.add(new EventScheduleItem(event_title, event_subtitle, event_start_time, event_end_time, event_location, event_date, event_authors, event_type, event_abstract)); //get index of this added item now int eventAddedIndex = eventsRecordsArray.size() - 1; //add it now to main records array scheduleRecordsArray .add(new ScheduleItemRecord(SCHEDULE_ITEMTYPE_EVENT, eventAddedIndex, event_date)); //closing if } else if (scheduleItemJsonObject.has("chair")) { // 'chair' key is only in track //parse the track parseScheduleTrackJSON(counter, scheduleItemJsonObject); //closing elseif } else if (scheduleItemJsonObject.has("tracks")) { // 'tracks' key is only in session String session_title = scheduleItemJsonObject.getString("title"); Log.i(LOG_TAG, "SESSION - title: " + session_title); String session_subtitle = scheduleItemJsonObject.getString("subtitle"); Log.i(LOG_TAG, "SESSION - subtitle: " + session_subtitle); Log.i(LOG_TAG, "SESSION - Start parsing Tracks"); JSONArray sessionTracksArray = scheduleItemJsonObject.getJSONArray("tracks"); //add the session to sessions list and initialize the tracks array to size of tracks in session sessionRecordsArray.add( new SessionScheduleItem(session_title, session_subtitle, sessionTracksArray.length())); //get index of added session in the list int addedSessionIndex = sessionRecordsArray.size() - 1; String tempSessionDate = sessionTracksArray.getJSONObject(0).getJSONArray("events") .getJSONObject(0).getString("date"); Log.i(LOG_TAG, "Session - " + session_title + " - Date: " + tempSessionDate); //add it now to main records array scheduleRecordsArray.add( new ScheduleItemRecord(SCHEDULE_ITEMTYPE_SESSION, addedSessionIndex, tempSessionDate)); //get the session added at this index tempSession = sessionRecordsArray.get(addedSessionIndex); for (int trackCounter = 0; trackCounter < sessionTracksArray.length(); trackCounter++) { //get Track object JSONObject sessionTrackObject = sessionTracksArray.getJSONObject(trackCounter); //parse the track object parseSessionTrackJSON(trackCounter, sessionTrackObject); } //add session back - update sessionRecordsArray.set(addedSessionIndex, tempSession); Log.i(LOG_TAG, "SESSION - End parsing Tracks"); } } } catch (Exception e) { // TODO: handle exception Log.getStackTraceString(e); } }
From source file:net.xisberto.phonetodesktop.network.GoogleTasksService.java
@Override protected void onHandleIntent(Intent intent) { if (intent != null) { final String action = intent.getAction(); Utils.log("onHandleIntent " + intent.getAction()); long[] tasks_ids; try {//from w w w. j a v a 2 s. c o m if (action.equals(Utils.ACTION_PROCESS_TASK)) { long task_id = intent.getLongExtra(Utils.EXTRA_TASK_ID, -1); LocalTask task = DatabaseHelper.getInstance(this).getTask(task_id); final Intent result = new Intent(Utils.ACTION_RESULT_PROCESS_TASK); result.putExtra(Utils.EXTRA_TASK_ID, task.getLocalId()); if (isOnline()) { processOptions(task); task.persistBlocking(new PersistCallback() { @Override public void run() { if (cache_unshorten != null) { result.putExtra(Utils.EXTRA_CACHE_UNSHORTEN, cache_unshorten); } if (cache_titles != null) { result.putExtra(Utils.EXTRA_CACHE_TITLES, cache_titles); } LocalBroadcastManager.getInstance(GoogleTasksService.this).sendBroadcast(result); } }); } else { tasks_ids = intent.getLongArrayExtra(Utils.EXTRA_TASKS_IDS); revertTaskToReady(tasks_ids); LocalBroadcastManager.getInstance(this).sendBroadcast(result); } } else if (action.equals(Utils.ACTION_SEND_TASKS)) { if (isOnline()) { tasks_ids = intent.getLongArrayExtra(Utils.EXTRA_TASKS_IDS); if (tasks_ids.length == 1) { DatabaseHelper databaseHelper = DatabaseHelper.getInstance(this); LocalTask task = databaseHelper.getTask(tasks_ids[0]); handleActionSend(task); } else { handleActionSendMultiple(tasks_ids); } stopForeground(true); } else { tasks_ids = intent.getLongArrayExtra(Utils.EXTRA_TASKS_IDS); revertTaskToReady(tasks_ids); ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).notify( NOTIFICATION_SEND_LATER, buildNotification(NOTIFICATION_SEND_LATER).build()); } } else if (action.equals(Utils.ACTION_LIST_TASKS)) { handleActionList(); } else if (action.equals(Utils.ACTION_REMOVE_TASKS)) { handleActionRemove(intent.getStringArrayListExtra(Utils.EXTRA_TASKS_IDS)); } } catch (UserRecoverableAuthIOException userRecoverableException) { Utils.log(Log.getStackTraceString(userRecoverableException)); stopForeground(true); tasks_ids = intent.getLongArrayExtra(Utils.EXTRA_TASKS_IDS); revertTaskToReady(tasks_ids); ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).notify(NOTIFICATION_NEED_AUTHORIZE, buildNotification(NOTIFICATION_NEED_AUTHORIZE).build()); } catch (IOException ioException) { Utils.log(Log.getStackTraceString(ioException)); if (action.equals(Utils.ACTION_SEND_TASKS)) { tasks_ids = intent.getLongArrayExtra(Utils.EXTRA_TASKS_IDS); stopForeground(true); revertTaskToReady(tasks_ids); ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).notify(NOTIFICATION_ERROR, buildNotification(NOTIFICATION_ERROR).build()); } else { Intent broadcast = new Intent(Utils.ACTION_LIST_TASKS); broadcast.putExtra(Utils.EXTRA_ERROR_TEXT, getString(R.string.txt_error_list)); LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast); } } catch (NullPointerException npe) { tasks_ids = intent.getLongArrayExtra(Utils.EXTRA_TASKS_IDS); Utils.log(Log.getStackTraceString(npe)); stopForeground(true); revertTaskToReady(tasks_ids); ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).notify(NOTIFICATION_NEED_AUTHORIZE, buildNotification(NOTIFICATION_NEED_AUTHORIZE).build()); } } }
From source file:edu.umich.flowfence.testapp.PerfActivity.java
private void showAlert(Throwable t) { if (t != null) { new AlertDialog.Builder(this).setTitle(R.string.perf_failed_title) .setMessage(Log.getStackTraceString(t)).show(); }/*from www. ja v a 2 s . c o m*/ }
From source file:com.tmall.wireless.tangram.support.ExposureSupport.java
/** * Handler exposure event on item// w w w . java 2s.com * * @param targetView the view that trigger the exposure event, not the view respond the cell! * @param cell the corresponding cell * @param type exposure event type, defined by developer. */ public void onTrace(@NonNull View targetView, @NonNull BaseCell cell, int type) { if (optimizedMode) { defaultTrace(targetView, cell, type); } else { if (mOnExposureMethods.isEmpty() || mOnTraceMethods.isEmpty()) { Method[] methods = this.getClass().getMethods(); findTraceMethods(methods); findExposureMethods(methods); } List<Class<?>> classes = lookupCellTypes(targetView.getClass()); for (Class clz : classes) { if (clz.equals(View.class)) { continue; } if (mOnTraceMethods.containsKey(clz)) { OnTraceMethod onTraceMethod = mOnTraceMethods.get(clz); try { if (onTraceMethod.paramLength == 3) { onTraceMethod.method.invoke(this, targetView, cell, type); return; } } catch (Exception e) { LogUtils.e(TAG, "Invoke Trace method error: " + Log.getStackTraceString(e), e); } } } defaultTrace(targetView, cell, type); } }
From source file:com.android.mms.transaction.ReadRecTransaction.java
public void run() { MmsLog.d(MmsApp.TXN_TAG, "ReadRecTransaction: process()"); // prepare for ReadRec int readReportState = 0; String messageId = null;//from w w w .ja v a 2 s . co m long msgId = 0; EncodedStringValue[] sender = new EncodedStringValue[1]; Cursor cursor = null; cursor = SqliteWrapper.query(mContext, mContext.getContentResolver(), mUri, new String[] { Mms.MESSAGE_ID, Mms.READ_REPORT, Mms._ID }, null, null, null); if (cursor != null) { try { if (cursor.moveToFirst()) { messageId = cursor.getString(0); readReportState = cursor.getInt(1); msgId = cursor.getLong(2); } // if curosr==null, this means the mms is deleted during // processing. // exception will happened. catched by out catch clause. // so do not catch exception here. } finally { cursor.close(); } } MmsLog.d(MmsApp.TXN_TAG, "messageid:" + messageId + ",and readreport flag:" + readReportState + ", mSubId = " + mSubId); cursor = null; cursor = SqliteWrapper.query(mContext, mContext.getContentResolver(), Uri.parse("content://mms/" + msgId + "/addr"), new String[] { Mms.Addr.ADDRESS, Mms.Addr.CHARSET }, Mms.Addr.TYPE + " = " + PduHeaders.FROM, null, null); if (cursor != null) { try { if (cursor.moveToFirst()) { String address = cursor.getString(0); int charSet = cursor.getInt(1); MmsLog.d(MmsApp.TXN_TAG, "find address:" + address + ",charset:" + charSet); sender[0] = new EncodedStringValue(charSet, PduPersister.getBytes(address)); } // if cursor == null exception will catched by out catch clause. } finally { cursor.close(); } } try { ReadRecInd readRecInd = new ReadRecInd( new EncodedStringValue(PduHeaders.FROM_INSERT_ADDRESS_TOKEN_STR.getBytes()), messageId.getBytes(), PduHeaders.CURRENT_MMS_VERSION, PduHeaders.READ_STATUS_READ, // always // set // read. sender); readRecInd.setDate(System.currentTimeMillis() / 1000); Uri uri = PduPersister.getPduPersister(mContext).persist(readRecInd, Mms.Outbox.CONTENT_URI, true, MmsPreferenceActivity.getIsGroupMmsEnabled(mContext), null); byte[] datas = new PduComposer(mContext, readRecInd).make(); mPduFile = createPduFile(datas, READREP_REQ_NAME + uri.getLastPathSegment()); if (mPduFile == null) { Log.e(MmsApp.TXN_TAG, "create pdu file req failed!"); return; } //Intent intent = new Intent(TransactionService.ACTION_TRANSACION_PROCESSED); //intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, mSubId); //intent.putExtra(TransactionBundle.URI, mUri.toString()); Log.d(MmsApp.TXN_TAG, "ReadRecTransaction mUri:" + mUri); final Intent intent = new Intent(TransactionService.ACTION_TRANSACION_PROCESSED, mUri, mContext, MmsReceiver.class); intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, mSubId); PendingIntent sentIntent = PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); Uri pduFileUri = FileProvider.getUriForFile(mContext, MMS_FILE_PROVIDER_AUTHORITIES, mPduFile); SmsManager.getSmsManagerForSubscriptionId(mSubId).sendMultimediaMessage(mContext, pduFileUri, null, null, sentIntent); } catch (InvalidHeaderValueException e) { Log.e(TAG, "Invalide header value", e); getState().setState(FAILED); getState().setContentUri(mUri); notifyObservers(); } catch (MmsException e) { Log.e(TAG, "Persist message failed", e); getState().setState(FAILED); getState().setContentUri(mUri); notifyObservers(); } catch (Throwable t) { Log.e(TAG, Log.getStackTraceString(t)); getState().setState(FAILED); getState().setContentUri(mUri); notifyObservers(); } }
From source file:com.dm.wallpaper.board.fragments.WallpaperSearchFragment.java
private void getWallpapers() { mGetWallpapers = new AsyncTask<Void, Void, Boolean>() { List<Wallpaper> wallpapers; @Override// w ww .j ava 2s . co m protected void onPreExecute() { super.onPreExecute(); wallpapers = new ArrayList<>(); } @Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); wallpapers = Database.get(getActivity()).getFilteredWallpapers(); return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; } @Override protected void onPostExecute(Boolean aBoolean) { super.onPostExecute(aBoolean); if (aBoolean) { mAdapter = new WallpapersAdapter(getActivity(), wallpapers, false, true); mRecyclerView.setAdapter(mAdapter); if (mSearchView != null) mSearchView.requestFocus(); SoftKeyboardHelper.openKeyboard(getActivity()); } } }.execute(); }