本文整理了Java中android.os.Bundle.get()
方法的一些代码示例,展示了Bundle.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.get()
方法的具体详情如下:
包路径:android.os.Bundle
类名称:Bundle
方法名:get
暂无
代码示例来源:origin: stackoverflow.com
public class MessageReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Bundle pudsBundle = intent.getExtras();
Object[] pdus = (Object[]) pudsBundle.get("pdus");
SmsMessage messages =SmsMessage.createFromPdu((byte[]) pdus[0]);
Log.i(TAG, messages.getMessageBody());
if(messages.getMessageBody().contains("Hi")) {
abortBroadcast();
}
}
代码示例来源:origin: stackoverflow.com
Bundle myBundle = intent.getExtras();
SmsMessage [] messages = null;
String strMessage = "";
Object [] pdus = (Object[]) myBundle.get("pdus");
代码示例来源:origin: ankidroid/Anki-Android
if (resultCode != RESULT_CANCELED) {
Collection col = getCol();
Bundle extras = data.getExtras();
int index = extras.getInt(MultimediaEditFieldActivity.EXTRA_RESULT_FIELD_INDEX);
IField field = (IField) extras.get(MultimediaEditFieldActivity.EXTRA_RESULT_FIELD);
IMultimediaEditableNote mNote = NoteService.createEmptyNote(mEditorNote.model());
NoteService.updateMultimediaNoteFromJsonNote(col, mEditorNote, mNote);
代码示例来源:origin: stackoverflow.com
@Override
public void onReceive(Context context, Intent intent)
{
Bundle extras = intent.getExtras();
if (extras == null)
return;
Object[] pdus = (Object[]) extras.get("pdus");
SmsMessage msg = SmsMessage.createFromPdu((byte[]) pdus[0]);
String origNumber = msg.getOriginatingAddress();
String msgBody = msg.getMessageBody();
...
...
}
代码示例来源:origin: facebook/facebook-android-sdk
private LoginClient.Result handleResultOk(LoginClient.Request request, Intent data) {
Bundle extras = data.getExtras();
String error = getError(extras);
String errorCode = extras.get("error_code") != null
? extras.get("error_code").toString()
: null;
String errorMessage = getErrorMessage(extras);
String e2e = extras.getString(NativeProtocol.FACEBOOK_PROXY_AUTH_E2E_KEY);
if (!Utility.isNullOrEmpty(e2e)) {
logWebLoginCompleted(e2e);
}
if (error == null && errorCode == null && errorMessage == null) {
try {
AccessToken token = createAccessTokenFromWebBundle(request.getPermissions(),
extras, AccessTokenSource.FACEBOOK_APPLICATION_WEB,
request.getApplicationId());
return LoginClient.Result.createTokenResult(request, token);
} catch (FacebookException ex) {
return LoginClient.Result.createErrorResult(request, null, ex.getMessage());
}
} else if (ServerProtocol.errorsProxyAuthDisabled.contains(error)) {
return null;
} else if (ServerProtocol.errorsUserCanceled.contains(error)) {
return LoginClient.Result.createCancelResult(request, null);
} else {
return LoginClient.Result.createErrorResult(request, error, errorMessage, errorCode);
}
}
代码示例来源:origin: stackoverflow.com
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (RESULT_OK == resultCode) {
// Get Extra from the intent
Bundle extras = data.getExtras();
// Get the returned image from extra
Bitmap bmp = (Bitmap) extras.get("data");
iv = (ImageView) findViewById(R.id.ReturnedImageView);
iv.setImageBitmap(bmp);
}
}
代码示例来源:origin: stackoverflow.com
public class SmsListener extends BroadcastReceiver{
private SharedPreferences preferences;
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
if(intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")){
Bundle bundle = intent.getExtras(); //---get the SMS message passed in---
SmsMessage[] msgs = null;
String msg_from;
if (bundle != null){
//---retrieve the SMS message received---
try{
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for(int i=0; i<msgs.length; i++){
msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
msg_from = msgs[i].getOriginatingAddress();
String msgBody = msgs[i].getMessageBody();
}
}catch(Exception e){
// Log.d("Exception caught",e.getMessage());
}
}
}
}
}
代码示例来源:origin: googlesamples/android-testing
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// If an image is received, display it on the ImageView.
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
if (extras == null || !extras.containsKey(KEY_IMAGE_DATA)) {
return;
}
Bitmap imageBitmap = (Bitmap) extras.get(KEY_IMAGE_DATA);
mImageView.setImageBitmap(imageBitmap);
}
}
}
代码示例来源:origin: stackoverflow.com
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
Uri uri = (Uri)bundle.get(Intent.EXTRA_STREAM);
代码示例来源:origin: stackoverflow.com
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
Bundle extras = intent.getExtras();
if(extras == null)
Log.d("Service","null");
else
{
Log.d("Service","not null");
String from = (String) extras.get("From");
if(from.equalsIgnoreCase("Main"))
StartListenLocation();
}
}
代码示例来源:origin: stackoverflow.com
public class newclass extends Activity
{
private TextView Textv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.intent);
Textv = (TextView)findViewById(R.id.tv2);
Intent iin= getIntent();
Bundle b = iin.getExtras();
if(b!=null)
{
String j =(String) b.get("name");
Textv.setText(j);
}
}
}
代码示例来源:origin: stackoverflow.com
import java.util.Iterator;
import java.util.Set;
import android.os.Bundle;
public static void dumpIntent(Intent i){
Bundle bundle = i.getExtras();
if (bundle != null) {
Set<String> keys = bundle.keySet();
Iterator<String> it = keys.iterator();
Log.e(LOG_TAG,"Dumping Intent start");
while (it.hasNext()) {
String key = it.next();
Log.e(LOG_TAG,"[" + key + "=" + bundle.get(key)+"]");
}
Log.e(LOG_TAG,"Dumping Intent end");
}
}
代码示例来源:origin: stackoverflow.com
public void onReceive(Context context, Intent intent)
Bundle extras = intent.getExtras();
Object[] smsextras = (Object[]) extras.get( "pdus" );
代码示例来源:origin: stackoverflow.com
Intent serviceIntent = new Intent(this,ListenLocationService.class);
serviceIntent.putExtra("From", "Main");
startService(serviceIntent);
//and get the parameter in onStart method of your service class
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
Bundle extras = intent.getExtras();
if(extras == null) {
Log.d("Service","null");
} else {
Log.d("Service","not null");
String from = (String) extras.get("From");
if(from.equalsIgnoreCase("Main"))
StartListenLocation();
}
}
代码示例来源:origin: stackoverflow.com
Bundle myBundle = intent.getExtras();
SmsMessage [] messages = null;
String strMessage = "";
Object [] pdus = (Object[]) myBundle.get("pdus");
messages = new SmsMessage[pdus.length];
代码示例来源:origin: stackoverflow.com
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String str = "";
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for (int i=0; i<msgs.length; i++){
代码示例来源:origin: cSploit/android
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
if(requestCode == PICK_DIRECTORY && resultCode == RESULT_OK){
Bundle extras = data.getExtras();
String path = (String) (extras != null ? extras.get(DirectoryPicker.CHOSEN_DIRECTORY) : null);
returnDir(path);
}
}
代码示例来源:origin: stackoverflow.com
public class LocationReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//Do this when the system sends the intent
Bundle b = intent.getExtras();
Location loc = (Location)b.get(android.location.LocationManager.KEY_LOCATION_CHANGED);
Toast.makeText(context, loc.toString(), Toast.LENGTH_SHORT).show();
}
}
代码示例来源:origin: stackoverflow.com
Bundle extras = intent.getExtras();
if (extras != null) {
Object[] pdus = (Object[])extras.get("pdus");
代码示例来源:origin: square/assertj-android
public IntentAssert hasExtra(String name, Object expectedValue) {
hasExtra(name);
Object actualValue = this.actual.getExtras().get(name);
assertThat(actualValue)
.overridingErrorMessage("Expected extra <%s> to be <%s> but was <%s>.", name, expectedValue, actualValue)
.isEqualTo(expectedValue);
return this;
}
内容来源于网络,如有侵权,请联系作者删除!