本文整理了Java中android.os.Message.getData()
方法的一些代码示例,展示了Message.getData()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getData()
方法的具体详情如下:
包路径:android.os.Message
类名称:Message
方法名:getData
暂无
代码示例来源:origin: stackoverflow.com
final Message msg = Message.obtain(null, 0);
msg.getData().putParcelable("DOWNLOADFILEURLITEM", downloadFileURLItem);
messenger.send(msg);
代码示例来源:origin: stackoverflow.com
private class GeocoderHandler extends Handler {
@Override
public void handleMessage(Message message) {
String result;
switch (message.what) {
case 1:
Bundle bundle = message.getData();
result = bundle.getString("address");
break;
default:
result = null;
}
// replace by what you need to do
myLabel.setText(result);
}
}
代码示例来源:origin: guardianproject/haven
@Override
public void handleMessage(Message msg) {
//only accept alert if monitor is running
if (mIsMonitoringActive)
alert(msg.what,msg.getData().getString(KEY_PATH));
}
}
代码示例来源:origin: guardianproject/haven
@Override
public void recordingComplete(String path) {
Message message = new Message();
message.what = EventTrigger.MICROPHONE;
message.getData().putString("path",path);
try {
if (serviceMessenger != null)
serviceMessenger.send(message);
} catch (RemoteException e) {
// Cannot happen
}
}
});
代码示例来源:origin: stackoverflow.com
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
Bundle reply = msg.getData();
// do whatever with the bundle here
}
};
代码示例来源:origin: mttkay/ignition
protected final void handleImageLoadedMessage(Message msg) {
Bundle data = msg.getData();
Bitmap bitmap = data.getParcelable(BITMAP_EXTRA);
handleImageLoaded(bitmap, msg);
}
代码示例来源:origin: RobotiumTech/robotium
/**
* Here we process the Handler queue and save the bitmaps.
*
* @param message A Message containing the bitmap to save, and some metadata.
*/
public void handleMessage(Message message) {
synchronized (screenshotMutex) {
String name = message.getData().getString("name");
int quality = message.arg1;
Bitmap b = (Bitmap)message.obj;
if(b != null) {
saveFile(name, b, quality);
b.recycle();
}
else {
Log.d(LOG_TAG, "NULL BITMAP!!");
}
screenshotMutex.notify();
}
}
代码示例来源:origin: wangdan/AisenWeiBo
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
String key = msg.getData().getString("key");
if (!TextUtils.isEmpty(key)) {
List<AisenTextView> copyList = new ArrayList<>();
copyList.addAll(textViewList);
Iterator<AisenTextView> iterator = copyList.iterator();
while (iterator.hasNext()) {
AisenTextView textView = iterator.next();
SpannableString textSpannable = textSpannableCache.get(key);
if (key.equals(textView.textKey) && textSpannable != null) {
textView.setTextSpannable(textSpannable);
}
}
}
}
代码示例来源:origin: RobotiumTech/robotium
/**
* This method posts a Bitmap with meta-data to the Handler queue.
*
* @param bitmap the bitmap to save
* @param name the name of the file
* @param quality the compression rate. From 0 (compress for lowest size) to 100 (compress for maximum quality).
*/
public void saveBitmap(Bitmap bitmap, String name, int quality) {
Message message = this.obtainMessage();
message.arg1 = quality;
message.obj = bitmap;
message.getData().putString("name", name);
this.sendMessage(message);
}
代码示例来源:origin: guardianproject/haven
private void finishVideoEncoding ()
{
try {
encoder.finish();
if (serviceMessenger != null) {
Message message = new Message();
message.what = EventTrigger.CAMERA_VIDEO;
message.getData().putString(MonitorService.KEY_PATH, videoFile.getAbsolutePath());
try {
serviceMessenger.send(message);
} catch (RemoteException e) {
e.printStackTrace();
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
代码示例来源:origin: stackoverflow.com
public class DataRequestService extends Service {
private final class ServiceHandler extends Handler {
public ServiceHandler(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message msg) {
log.info("handleMessage");
//... performing some time-consuming operation
Bundle bundle = msg.getData();
PendingIntent receiver = bundle.getParcelable("receiver");
// Perform the operation associated with PendingIntent
try {
//you can attach data from the operation in the intent.
Intent intent = new Intent();
Bundle b = new Bundle();
//b.putString("key", value);
intent.putExtras(b);
receiver.send(getApplicationContext(), status, intent);
} catch (CanceledException e) {
e.printStackTrace();
}
}
}
@Override
public void onStart(Intent intent, int startId) {
Bundle bundle = intent.getExtras();
msg.setData(bundle);
mServiceHandler.sendMessage(msg);
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
private void handleStartMessage(Message message) {
final Bundle data = message.getData();
final Messenger replyTo = message.replyTo;
String tag = data.getString(REQUEST_PARAM_TAG);
if (replyTo == null || tag == null) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Invalid start execution message.");
}
return;
}
GooglePlayMessengerCallback messengerCallback = new GooglePlayMessengerCallback(replyTo, tag);
JobInvocation jobInvocation = googlePlayReceiver.prepareJob(messengerCallback, data);
googlePlayReceiver.getExecutionDelegator().executeJob(jobInvocation);
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
private void handleStopMessage(Message message) {
Builder builder = GooglePlayReceiver.getJobCoder().decode(message.getData());
if (builder == null) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Invalid stop execution message.");
}
return;
}
JobInvocation job = builder.build();
ExecutionDelegator.stopJob(job, true);
}
}
代码示例来源:origin: facebook/facebook-android-sdk
protected void handleMessage(Message message) {
if (message.what == replyMessage) {
Bundle extras = message.getData();
String errorType = extras.getString(NativeProtocol.STATUS_ERROR_TYPE);
if (errorType != null) {
callback(null);
} else {
callback(extras);
}
try {
context.unbindService(this);
} catch (IllegalArgumentException ex) {
// Do nothing, the connection was already unbound
}
}
}
代码示例来源:origin: stackoverflow.com
Bundle data = message.getData();
代码示例来源:origin: robolectric/robolectric
@Test
public void testGetDataShouldLazilyCreateBundle() throws Exception {
assertThat(new Message().getData()).isNotNull();
assertThat(new Message().getData().isEmpty()).isTrue();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testGetData() throws Exception {
Message m = new Message();
Bundle b = new Bundle();
m.setData(b);
assertThat(m.getData()).isEqualTo(b);
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@Test
public void jobFinished() throws Exception {
final ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
callback.jobFinished(JobService.RESULT_SUCCESS);
Mockito.verify(messengerMock).send(messageCaptor.capture());
Message message = messageCaptor.getValue();
assertEquals(GooglePlayMessageHandler.MSG_RESULT, message.what);
assertEquals(JobService.RESULT_SUCCESS, message.arg1);
assertEquals("tag", message.getData().getString(REQUEST_PARAM_TAG));
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testObtainWithMessage() throws Exception {
Bundle b = new Bundle();
Message m = new Message();
m.arg1 = 10;
m.arg2 = 42;
m.obj = "obj";
m.what = 24;
m.setData(b);
m.setTarget(new Handler());
Message m2 = Message.obtain(m);
assertThat(m2.arg1).isEqualTo(m.arg1);
assertThat(m2.arg2).isEqualTo(m.arg2);
assertThat(m2.obj).isEqualTo(m.obj);
assertThat(m2.what).isEqualTo(m.what);
assertThat(m2.getTarget()).isEqualTo(m.getTarget());
assertThat(m2.getData()).isNotNull();
assertThat(m2.getData().isEmpty()).isTrue();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testCopyFrom() throws Exception {
Bundle b = new Bundle();
Message m = new Message();
m.arg1 = 10;
m.arg2 = 42;
m.obj = "obj";
m.what = 24;
m.setData(b);
m.setTarget(new Handler());
Message m2 = new Message();
m2.copyFrom(m);
assertThat(m2.arg1).isEqualTo(m.arg1);
assertThat(m2.arg2).isEqualTo(m.arg2);
assertThat(m2.obj).isEqualTo(m.obj);
assertThat(m2.what).isEqualTo(m.what);
assertThat(m2.getTarget()).isNull();
assertThat(m2.getData()).isNotNull();
assertThat(m2.getData().isEmpty()).isTrue();
}
内容来源于网络,如有侵权,请联系作者删除!