List of usage examples for android.graphics BitmapFactory decodeResource
public static Bitmap decodeResource(Resources res, int id)
From source file:com.bullmobi.message.ui.activities.MainActivity.java
private static void sendTestNotification(@NonNull Context context) { final int id = App.ID_NOTIFY_TEST; final Resources res = context.getResources(); PendingIntent pendingIntent = PendingIntent.getActivity(context, id, new Intent(context, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.BigTextStyle bts = new NotificationCompat.BigTextStyle() .bigText(res.getString(R.string.notification_test_message_large)); NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setContentTitle(res.getString(R.string.app_name)) .setContentText(res.getString(R.string.notification_test_message)).setContentIntent(pendingIntent) .setLargeIcon(BitmapFactory.decodeResource(res, R.mipmap.ic_launcher)) .setSmallIcon(R.drawable.stat_easynotification).setAutoCancel(true).setStyle(bts) .setColor(App.ACCENT_COLOR)//from w ww.jav a2s .c o m .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(id, builder.build()); }
From source file:com.classiqo.nativeandroid_32bitz.ui.BaseActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LogHelper.d(TAG, "Activity onCreate"); if (Build.VERSION.SDK_INT >= 21) { ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(getTitle().toString(), BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_white), ResourceHelper.getThemeColor(this, R.attr.colorPrimary, android.R.color.darker_gray)); setTaskDescription(taskDesc);/*from www. j av a2 s .c om*/ } mMediaBrowser = new MediaBrowserCompat(this, new ComponentName(this, MusicService.class), mConnectionCallback, null); }
From source file:com.actinarium.nagbox.common.ViewUtils.java
/** * Set custom icon and color for recents screen card * * @param activity Activity to configure * @param colorRes Color resource for recents screen card title * @param icon Bitmap drawable resource to draw into recents screen card title */// ww w . j a v a 2s .c o m public static void setupRecentsIcon(Activity activity, @ColorRes int colorRes, @DrawableRes int icon) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { return; } int color = ContextCompat.getColor(activity, colorRes); Bitmap bm = BitmapFactory.decodeResource(activity.getResources(), icon); ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(null, bm, color); activity.setTaskDescription(td); bm.recycle(); }
From source file:com.cls.sugutomo.map.ClusterOP.java
public ClusterOP(Resources resources) { baseBitmaps = new Bitmap[res.length]; for (int i = 0; i < res.length; i++) { baseBitmaps[i] = BitmapFactory.decodeResource(resources, res[i]); }// w ww .ja va 2s . c o m paint.setColor(Color.WHITE); paint.setTextAlign(Align.CENTER); paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); paint.setTextSize(resources.getDimension(R.dimen.text_size)); }
From source file:cn.studyjams.s2.sj0119.NForget.AlarmReceiver.java
@Override public void onReceive(Context context, Intent intent) { int mReceivedID = Integer.parseInt(intent.getStringExtra(ReminderEditActivity.EXTRA_REMINDER_ID)); // Get notification title from Reminder Database ReminderDatabase rb = new ReminderDatabase(context); Reminder reminder = rb.getReminder(mReceivedID); String mTitle = reminder.getTitle(); // Create intent to open ReminderEditActivity on notification click Intent editIntent = new Intent(context, ReminderEditActivity.class); editIntent.putExtra(ReminderEditActivity.EXTRA_REMINDER_ID, Integer.toString(mReceivedID)); PendingIntent mClick = PendingIntent.getActivity(context, mReceivedID, editIntent, PendingIntent.FLAG_UPDATE_CURRENT); // Create Notification NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher)) .setSmallIcon(R.drawable.ic_alarm_on_white_24dp) .setContentTitle(context.getResources().getString(R.string.app_name)).setTicker(mTitle) .setContentText(mTitle).setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setContentIntent(mClick).setAutoCancel(true).setOnlyAlertOnce(true); NotificationManager nManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nManager.notify(mReceivedID, mBuilder.build()); }
From source file:com.ecml.ChooseSongActivity.java
@Override public void onCreate(Bundle state) { globalActivity = this; super.onCreate(state); // Set the Action Bar Title of the Activity (corresponding to the first Tab) setTitle("ECML: Choose Song"); Bitmap allFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.allfilesicon); Bitmap recentFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.recentfilesicon); Bitmap browseFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.browsefilesicon); final TabHost tabHost = getTabHost(); tabHost.addTab(tabHost.newTabSpec("All").setIndicator("All", new BitmapDrawable(allFilesIcon)) .setContent(new Intent(this, AllSongsActivity.class))); tabHost.addTab(tabHost.newTabSpec("Recent").setIndicator("Recent", new BitmapDrawable(recentFilesIcon)) .setContent(new Intent(this, RecentSongsActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))); tabHost.addTab(tabHost.newTabSpec("Browse").setIndicator("Browse", new BitmapDrawable(browseFilesIcon)) .setContent(new Intent(this, FileBrowserActivity.class))); tabHost.setOnTabChangedListener(this); }
From source file:com.alibaba.cloudapi.client.MainActivity.java
public void sendHttpPostBytes(View view) { final Intent intent = new Intent(this, DisplayMessageActivity.class); Runnable runnable = new Runnable() { @Override/*from w ww .j a v a 2 s.c o m*/ public void run() { String getPath = "/rest/160601/ocr/ocr_idcard.json"; String imgBase64 = bitmaptoString(BitmapFactory.decodeResource(getResources(), R.drawable.sfz)); // bodyjson JSONObject requestObj = new JSONObject(); try { JSONObject configObj = new JSONObject(); JSONObject obj = new JSONObject(); JSONArray inputArray = new JSONArray(); configObj.put("side", "face"); obj.put("image", getParam(50, imgBase64)); obj.put("configure", getParam(50, configObj.toString())); inputArray.put(obj); requestObj.put("inputs", inputArray); } catch (JSONException e) { e.printStackTrace(); } String content = requestObj.toString(); Log.w("data", content); //---------- // String content = "Hi there ,this is string"; HttpUtil.getInstance().httpPostBytes(getPath, null, null, content.getBytes(Constants.CLOUDAPI_ENCODING), null, new Callback() { @Override public void onFailure(Call call, IOException e) { intent.putExtra(EXTRA_MESSAGE, e.getMessage()); startActivity(intent); } @Override public void onResponse(Call call, Response response) throws IOException { intent.putExtra(EXTRA_MESSAGE, getResultString(response)); startActivity(intent); } }); } }; new Thread(runnable).start(); }
From source file:edu.mit.mobile.android.imagecache.test.ImageCacheJunitTest.java
public void testGetPut() throws IOException { final Context contextInst = getInstrumentation().getContext(); testClear();/*from www.j ava2 s . c o m*/ final String key01 = "foo"; final String key02 = "bar"; Bitmap bmp = BitmapFactory.decodeResource(contextInst.getResources(), R.drawable.ic_launcher); assertTrue(bmp.getHeight() > 0); assertTrue(bmp.getWidth() > 0); imc.put(key01, bmp); assertEquals(1, imc.getCacheEntryCount()); Bitmap bmpResult = imc.get(key01); assertNotNull(bmpResult); // check dimensions assertBitmapEqual(bmp, bmpResult); // check contents to ensure it's the same // TODO bmp = BitmapFactory.decodeResource(contextInst.getResources(), android.R.drawable.ic_dialog_alert); assertTrue(bmp.getHeight() > 0); assertTrue(bmp.getWidth() > 0); // call it again, ensure we overwrite imc.put(key01, bmp); assertEquals(1, imc.getCacheEntryCount()); bmpResult = imc.get(key01); assertNotNull(bmpResult); // check dimensions assertBitmapEqual(bmp, bmpResult); // test to make sure an empty result returns null assertNull(imc.get(key02)); testClear(); }
From source file:com.android.settings.service.AlarmService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { try {/* w w w . ja va 2 s . c o m*/ startAlarmSound(); } catch (Exception e) { // Do nothing } Bundle extras = intent.getExtras(); String names = extras.getString("number"); String title = getResources().getString(R.string.quiet_hours_alarm_dialog_title); Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_quiethours); NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setTicker(title) .setContentTitle(title).setContentText(names).setAutoCancel(false).setOngoing(true) .setSmallIcon(R.drawable.ic_quiethours).setLargeIcon(bm) .setStyle(new NotificationCompat.BigTextStyle() .bigText(names + getResources().getString(R.string.quiet_hours_alarm_message))); Intent alarmDialog = new Intent(); alarmDialog.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); alarmDialog.setClass(this, com.android.settings.service.BypassAlarm.class); alarmDialog.putExtra("number", names); alarmDialog.putExtra("norun", true); PendingIntent result = PendingIntent.getActivity(this, 0, alarmDialog, PendingIntent.FLAG_CANCEL_CURRENT); builder.setContentIntent(result); mManager.notify(NOTI_ID, builder.build()); return START_STICKY; }
From source file:com.android.settings.slim.service.AlarmService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { try {// w w w .ja va2 s. co m startAlarmSound(); } catch (Exception e) { // Do nothing } Bundle extras = intent.getExtras(); String names = extras.getString("number"); String title = getResources().getString(R.string.quiet_hours_alarm_dialog_title); Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_quiethours); NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setTicker(title) .setContentTitle(title).setContentText(names).setAutoCancel(false).setOngoing(true) .setSmallIcon(R.drawable.ic_quiethours).setLargeIcon(bm) .setStyle(new NotificationCompat.BigTextStyle() .bigText(names + getResources().getString(R.string.quiet_hours_alarm_message))); Intent alarmDialog = new Intent(); alarmDialog.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); alarmDialog.setClass(this, com.android.settings.slim.service.BypassAlarm.class); alarmDialog.putExtra("number", names); alarmDialog.putExtra("norun", true); PendingIntent result = PendingIntent.getActivity(this, 0, alarmDialog, PendingIntent.FLAG_CANCEL_CURRENT); builder.setContentIntent(result); mManager.notify(NOTI_ID, builder.build()); return START_STICKY; }