jjzjj

getBaseContext

全部标签

android - android 中的 MyMapOverlay 类型未定义方法 getBaseContext()?为什么?

我正在创建一个类似Geocoder的对象。GeocodergeoCoder=newGeocoder(getBaseContext(),Locale.getDefault());我在eclipse中遇到了这个错误。即ThemethodgetBaseContext()isundefinedforthetypeMyMapOverlaygetBaseContext()是android.content.ContextWrapper类中的默认方法。这里有什么问题..有什么想法吗??? 最佳答案 问题是:在哪个类中创建Geocoder对象?get

Android SMS Delivery Broadcast 接收器在模拟器中不工作

我正在创建一个具有发送短信模块的应用程序。我正在使用2个广播接收器和PendingIntent,一个用于发送确认短信,另一个用于发送..发送的短信广播接收器工作正常,但没有送达。我在服务中使用以下代码。PendingIntentsentPI=PendingIntent.getBroadcast(this,0,newIntent(SENT),0);PendingIntentdeliveredPI=PendingIntent.getBroadcast(this,0,newIntent(DELIVERED),0);//---whentheSMShasbeensent---isworkinga

java - getBaseContext 还是 getContext?它们有何不同?

这个问题在这里已经有了答案:What'sthedifferencebetweenthevariousmethodstogetanAndroidContext?(8个答案)CansomeoneclarifyAndroidcontextreferences?(1个回答)关闭8年前。我注意到在我的类中扩展了View,为了获得屏幕尺寸,我必须使用getContextDisplayMetricsdispM=getContext.getResources().getDisplayMetrics();intwidth=dispM.WidthPixels;intheight=dispM.HeightP

Android SmsManger 发送报告

我向多个联系人发送多条消息,并为每个联系人使用以下代码privatevoidsendSMS(Stringfirst,Stringlast,Stringid,StringphoneNumber){try{Stringmessage;message=insertName(first,last);if(message.equals(null)||message.equals(""))message="\n";StringSENT="SMS_SENT";StringDELIVERED="SMS_DELIVERED";PendingIntentsentPI=PendingIntent.getBr

android - 从 Intent 中获取多个广播?

http://mobiforge.com/developing/story/sms-messaging-android我在上面的链接中使用了我自己的应用程序中的示例代码来发送短信,但是在检查我的消息的发送状态时遇到了问题。结果是,我尝试发送的每条消息都会弹出toast消息。所以基本上,假设我已经发送了3条消息。当我发送第4条消息时,toast消息将弹出4次。似乎BroadcastReceiver正在从目前使用的每个Intent接收相同的广播?我无法弄清楚为什么会这样,或者如何阻止它。任何帮助或见解将不胜感激!下面是导致这个的具体方法://---sendsanSMSmessagetoan

android - 以编程方式设置语言环境不起作用?

我有一个Activity,我以编程方式将语言环境设置为“de”,但它没有按预期工作,而是显示手动设置的默认语言(英文文本)。请帮忙publicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);//ProgrammaticallysetsthelocaleandlanguageLocalelocale=newLocale("de");Locale.setDefault(locale);Configurationconfig=newConfiguration();config.locale=l

android - 语言环境:未调用 onConfigurationChanged

我希望我的语言动态变化,我正在尝试使用onConfigurationChanged但它没有被调用。我有一个MainActivity创建我的操作栏和viewpager。我的其余页面是fragment。在我的SettingsFragment中,我有一个按钮可以将语言切换为法语。langChange.setOnClickListener(newOnClickListener(){@OverridepublicvoidonClick(Viewvi){MainActivitymain=(MainActivity)getActivity();main.langChange();}});然后在我的M

android - Runnable 中的上下文

我尝试播放来自R.raw的声音。在Thread/Runnable中但我无法让它工作。newRunnable(){publicvoidrun(){//thisisgivingmeaNullPointerException,becausegetBaseContextisnullMediaPlayermp=MediaPlayer.create(getBaseContext(),R.raw.soundfile);while(true){if(something)playsomething}}如何在run方法中获取真正的Context?无论我尝试什么,它都是空的。或者有更好的方法吗?

android - 在 android 中使用短信管理器发送短信时返回 RESULT_ERROR_GENERIC_FAILURE

我正在使用短信管理器向多个用户发送短信,但出现RESULT_ERROR_GENERIC_FAILURE(一般性故障)。如何解决此问题?//---sendsanSMSmessagetoanotherdevice---privatevoidsendSMS(StringphoneNumber,Stringmessage){StringSENT="SMS_SENT";StringDELIVERED="SMS_DELIVERED";PendingIntentsentPI=PendingIntent.getBroadcast(this,0,newIntent(SENT),0);PendingInt

Android Nougat 7.1 在启动 WebView 后重置 Locale

我们在AndroidN7.1(API-25)中遇到了一个奇怪的行为,即在启动WebView后,系统会强制将区域设置重置为设备区域设置。这会覆盖应用程序中使用的语言环境(用于本地化)。重现的简单方法是在应用程序上进行本地化。并启动WebView。然后您将不会再看到本地化内容,直到您再次重新启动应用程序。这仅发生在Android-7.1(API-25)上以下是我如何切换适用于所有API的语言环境:publicvoidswitchToCzLocale(){LocalemLocale=newLocale("cs","CZ");//itcanbeanyotherLocaleConfigurati