本文整理汇总了Java中android.os.Message.getData方法的典型用法代码示例。如果您正苦于以下问题:Java Message.getData方法的具体用法?Java Message.getData怎么用?Java Message.getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.Message
的用法示例。
在下文中一共展示了Message.getData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMessage
import android.os.Message; //导入方法依赖的package包/类
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case HANDLER_LOADING:
//实时更新进度
Bundle bundle = msg.getData();
long transferedBytes = bundle.getLong("transferedBytes");
long totalSize = bundle.getLong("totalSize");
mTvTextSize.setText(transferedBytes + "/" + totalSize);
//设置进度,百分比形式
mNumberProgressBar.setProgress((int) (((float)transferedBytes / (float) totalSize) *
100));
break;
case HANDLER_OK:
mTvTextSize.setText("下载成功");
//启动这个应用安装
startInstallApk();
break;
case HANDLER_FAIL:
mTvTextSize.setText("下载失败");
break;
}
}
示例2: handleMessage
import android.os.Message; //导入方法依赖的package包/类
public void handleMessage(Message msg) {
Bundle data = msg.getData();
switch (msg.what) {
case 1:
this.mServiceImpl.connect(data.getString(MediaBrowserProtocol.DATA_PACKAGE_NAME), data.getInt(MediaBrowserProtocol.DATA_CALLING_UID), data.getBundle(MediaBrowserProtocol.DATA_ROOT_HINTS), new ServiceCallbacksCompat(msg.replyTo));
return;
case 2:
this.mServiceImpl.disconnect(new ServiceCallbacksCompat(msg.replyTo));
return;
case 3:
this.mServiceImpl.addSubscription(data.getString(MediaBrowserProtocol.DATA_MEDIA_ITEM_ID), data.getBundle(MediaBrowserProtocol.DATA_OPTIONS), new ServiceCallbacksCompat(msg.replyTo));
return;
case 4:
this.mServiceImpl.removeSubscription(data.getString(MediaBrowserProtocol.DATA_MEDIA_ITEM_ID), data.getBundle(MediaBrowserProtocol.DATA_OPTIONS), new ServiceCallbacksCompat(msg.replyTo));
return;
case 5:
this.mServiceImpl.getMediaItem(data.getString(MediaBrowserProtocol.DATA_MEDIA_ITEM_ID), (ResultReceiver) data.getParcelable(MediaBrowserProtocol.DATA_RESULT_RECEIVER));
return;
case 6:
this.mServiceImpl.registerCallbacks(new ServiceCallbacksCompat(msg.replyTo));
return;
default:
Log.w(MediaBrowserServiceCompat.TAG, "Unhandled message: " + msg + "\n Service version: " + 1 + "\n Client version: " + msg.arg1);
return;
}
}
示例3: handleMessage
import android.os.Message; //导入方法依赖的package包/类
@Override
public void handleMessage(Message message) {
if (message.what == R.id.restart_preview) {
restartPreviewAndDecode();
} else if (message.what == R.id.decode_succeeded) {
state = State.SUCCESS;
Bundle bundle = message.getData();
activity.handleDecode((Result) message.obj, bundle);
} else if (message.what == R.id.decode_failed) {// We're decoding as fast as possible, so when one
// decode fails,
// start another.
state = State.PREVIEW;
cameraManager.requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
} else if (message.what == R.id.return_scan_result) {
activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
activity.finish();
}
}
示例4: handleMessage
import android.os.Message; //导入方法依赖的package包/类
@Override
public void handleMessage(Message message) {
if(message.what==R.id.restart_preview){
restartPreviewAndDecode();
}else if(message.what==R.id.decode_succeeded){
state = State.SUCCESS;
Bundle bundle = message.getData();
activity.handleDecode((Result) message.obj, bundle);
}else if(message.what==R.id.decode_failed){
// We're decoding as fast as possible, so when one decode fails,
// start another.
state = State.PREVIEW;
cameraManager.requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
}else if(message.what==R.id.return_scan_result){
activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
activity.finish();
}
}
示例5: onCreate
import android.os.Message; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = (RecyclerView) findViewById(R.id.recyclerview1);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(layoutManager);
recyclerViewAdapter = new RecyclerViewAdapter(pokemonList);
recyclerView.setAdapter(recyclerViewAdapter);
// Create a new handlerThread
handlerThread = new HandlerThread("MyHandler");
handlerThread.start();
//Attached a handler
handler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message msg) {
Bundle bundle = msg.getData();
String message = bundle.getString("message");
pokemonList.add(message) ;
recyclerViewAdapter.notifyDataSetChanged();
Log.d("message", "" + message);
}
};
final Button button = (Button) findViewById(R.id.pokemonButton);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
sendNewMessage();
}
});
}
示例6: putCredential
import android.os.Message; //导入方法依赖的package包/类
@Override
public void putCredential(String uri, String workgroup, String username, String password) {
try (final MessageValues messageValues = MessageValues.obtain()) {
final Message msg = mHandler.obtainMessage(PUT_CREDENTIAL, messageValues);
final Bundle args = msg.getData();
args.putString(URI_KEY, uri);
args.putString(WORKGROUP_KEY, workgroup);
args.putString(USERNAME_KEY, username);
args.putString(PASSWORD_KEY, password);
enqueue(msg);
}
}
示例7: MessageReader
import android.os.Message; //导入方法依赖的package包/类
private MessageReader(Message message) {
what = message.what;
object = (Parcelable) message.obj;
replyTo = message.replyTo;
Bundle bundle = message.getData();
if (bundle != null && bundle.containsKey(MessageInitializer.KEY_SERIALIZABLE)) {
data = bundle.getSerializable(MessageInitializer.KEY_SERIALIZABLE);
} else {
data = null;
}
}
示例8: handleMessage
import android.os.Message; //导入方法依赖的package包/类
@Override
public void handleMessage(Message msgFromService) {
JKActivity activity = weakActivity.get();
if (null == activity) return;
switch (msgFromService.what) {
case Constant.MEDIA_PLAYER_SERVICE_SONG_PLAYING://通过Bundle传递对象,显示正在播放的歌曲
LogUtils.e(TAG, "收到消息了");
Bundle bundle = msgFromService.getData();
activity.mAdapter.showPlaying((MusicBean) bundle.getSerializable(Constant.MEDIA_PLAYER_SERVICE_MODEL_PLAYING));
activity.mAdapter.notifyDataSetChanged();
MusicBean musicBean = (MusicBean) bundle.getSerializable(Constant.MEDIA_PLAYER_SERVICE_MODEL_PLAYING);
activity.title.setText(musicBean.getSongname());
activity.artist.setText(musicBean.getSingername());
Glide.with(activity).load(musicBean.getAlbumpic_big()).into(activity.playcard);
break;
case Constant.MEDIA_PLAYER_SERVICE_IS_PLAYING:
LogUtils.d(TAG, "收到了来自service的信息:是否更新UI");
if (1 == msgFromService.arg1) {//正在播放
LogUtils.d(TAG, "play按钮触发");
activity.mBtnPlay.setImageResource(R.mipmap.bar_puase);
} else {
LogUtils.d(TAG, "pause按钮触发");
activity.mBtnPlay.setImageResource(R.mipmap.bar_play);
}
break;
case Constant.MEDIA_PLAYER_SERVICE_PROGRESS:
// LogUtils.d("LocalMusicActivity", "进度条开始工作");
activity.currentTime = msgFromService.arg1;
activity.duration = msgFromService.arg2;
if (0 == activity.duration) break;
activity.progressBar.setProgress(activity.currentTime * 100 / activity.duration);
break;
}
super.handleMessage(msgFromService);
}
示例9: handleMicroBitMessage
import android.os.Message; //导入方法依赖的package包/类
/**
* Handler of incoming messages from BLEListener.
*/
private void handleMicroBitMessage(Message msg) {
Bundle data = msg.getData();
CmdArg cmd = new CmdArg(data.getInt(IPCConstants.BUNDLE_DATA), data.getString(IPCConstants.BUNDLE_VALUE));
logi("handleMicrobitMessage() ## msg.arg1 = " + msg.arg1 + " ## data.getInt=" + data.getInt(IPCConstants
.BUNDLE_DATA) + " ## data.getString=" + data.getString(IPCConstants.BUNDLE_VALUE));
AbstractPlugin abstractPlugin = pluginsCreator.createPlugin(msg.arg1, pluginHandler);
if(abstractPlugin != null) {
abstractPlugin.handleEntry(cmd);
}
}
示例10: handleMessage
import android.os.Message; //导入方法依赖的package包/类
@Override
public void handleMessage(Message message) {
if (message.what == R.id.restart_preview) {
restartPreviewAndDecode();
} else if (message.what == R.id.decode_succeeded) {
state = State.SUCCESS;
Bundle bundle = message.getData();
Bitmap barcode = null;
float scaleFactor = 1.0f;
if (bundle != null) {
byte[] compressedBitmap = bundle.getByteArray(DecodeThread.BARCODE_BITMAP);
if (compressedBitmap != null) {
barcode = BitmapFactory.decodeByteArray(compressedBitmap, 0, compressedBitmap.length, null);
// Mutable copy:
barcode = barcode.copy(Bitmap.Config.ARGB_8888, true);
}
scaleFactor = bundle.getFloat(DecodeThread.BARCODE_SCALED_FACTOR);
}
activity.handleDecode((Result) message.obj, barcode, scaleFactor);
} else if (message.what == R.id.decode_failed) {// We're decoding as fast as possible, so when one decode fails, start another.
state = State.PREVIEW;
cameraManager.requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
} else if (message.what == R.id.return_scan_result) {
activity.getActivity().setResult(Activity.RESULT_OK, (Intent) message.obj);
activity.getActivity().finish();
}
}
示例11: handleMessage
import android.os.Message; //导入方法依赖的package包/类
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case HANDLER_LODING:
//实时更新进度
Bundle bundle = msg.getData();
long transferredBytes = bundle.getLong("transferredBytes");
long totalSize = bundle.getLong("totalSize");
tv_size.setText(transferredBytes + " / " + totalSize);
//设置进度
// 30% --- 100% number_progress_bar.setpar(30)
// 5200.0 / 52000.0 10.0% 10 / 100 = 100%
number_progress_bar.setProgress((int) (((float) transferredBytes / (float) totalSize) * 100));
break;
case HANDLER_OK:
tv_size.setText(R.string.text_Ddwnload_successful);
//启动这个应用安装
startInstallApk();
break;
case HANDLER_ON:
tv_size.setText(R.string.text_dwnload_failure);
break;
}
}
示例12: handleMessage
import android.os.Message; //导入方法依赖的package包/类
@Override
public void handleMessage(Message msg) {
Bundle bundle = msg.getData();
String error = bundle.getString(RemoteProcessService.BUNDLE_KEY_ERROR);
if (error != null) {
// Asserts and shows error from service process.
assertTrue(error, false);
}
}
示例13: handleMessage
import android.os.Message; //导入方法依赖的package包/类
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == RECEIVE_MESSAGE_CODE) {
Log.i(TAG, "PedometerService serviceHandler");
Bundle data = msg.getData();
if (data != null) {
TAG_STEP = data.getInt("TAG_STEP");
if (mPedometerCore != null) {
}
}
if (mClientMessenger == null) {
mClientMessenger = msg.replyTo;//这个Message是在客户端中创建的
}
if (mClientMessenger != null && mPedometerEntity != null) {
Message msgToClient = Message.obtain();
msgToClient.what = SEND_MESSAGE_CODE;
Bundle bundle = new Bundle();
bundle.putSerializable("msg", mPedometerEntity);
msgToClient.setData(bundle);
try {
mClientMessenger.send(msgToClient);
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
}
示例14: updateCacheStatus
import android.os.Message; //导入方法依赖的package包/类
private void updateCacheStatus(int type, int info, long[] segments) {
if (mEventHandler != null) {
Message m = mEventHandler.obtainMessage(MEDIA_CACHING_UPDATE);
Bundle b = m.getData();
b.putInt(MEDIA_CACHING_TYPE, type);
b.putInt(MEDIA_CACHING_INFO, info);
b.putLongArray(MEDIA_CACHING_SEGMENTS, segments);
mEventHandler.sendMessage(m);
}
}
示例15: p
import android.os.Message; //导入方法依赖的package包/类
private void p(Message message) {
Bundle data = message.getData();
data.setClassLoader(BDLocation.class.getClassLoader());
BDLocation bDLocation = (BDLocation) data.getParcelable("locStr");
if (this.jD == null) {
return;
}
if (this.jN == null || !this.jN.a() || bDLocation.getLocType() != 65) {
this.jD.onReceiveLocation(bDLocation);
}
}