草庐IT

login_context

全部标签

android - 使用 Locale.getDefault() 和 context.getResources().getConfiguration().locale 的语言环境有什么区别?

返回的字符串有什么区别吗:Locale.getDefault().toString()和context.getResources().getConfiguration().locale.toString()询问是因为我怀疑这会导致应用程序中出现错误,在使用Locale.getDefault().toString()之前有效的功能不再适用于context.getResources()。getConfiguration().locale.toString(),在某些美国设备上。但不确定是否是这个原因。谢谢! 最佳答案 Locale.ge

java - 尝试在空对象引用上调用虚拟方法 'android.os.Looper android.content.Context.getMainLooper()'

这个问题在这里已经有了答案:WhatisaNullPointerException,andhowdoIfixit?(12个答案)关闭5年前。每当我尝试在我的手机或模拟器上打开该应用程序时,我的Logcat中都会出现此错误。为了让您大致了解我目前正在做的项目,它是一个记录连接到手机接入点的设备数据的系统,可以通过屏幕上的按钮打开和关闭。我想归功于:Android2.3wifihotspotAPI和https://www.whitebyte.info/android/android-wifi-hotspot-manager-classLogcat文件的图像是:https://i.gyazo

android - 方法 checkSelfPermission(Context, String) 未定义类型 ContextCompat

Contextcontext;@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Contextcontext=(Permission)this;//Inanactualapp,you'dwanttorequestapermissionwhentheuser//performsanaction//thatrequiresthatpermission.if(Build.VERSIO

android - 执行 createChooser(context,intent,IntentSender) 后不调用 BroadcastReceiver

我想检测用户在我向他展示createChooser()对话框后选择的应用程序。所以我创建了我的BroadcastReceiver子类,如下所示:importandroid.content.BroadcastReceiver;importandroid.content.Context;importandroid.content.Intent;importandroid.util.Log;publicclassShareBroadcastReceiverextendsBroadcastReceiver{@OverridepublicvoidonReceive(Contextcontext,

android - 我应该在 AsyncTask 中使用 Wea​​kReference<Context> 还是 Application Context?

我有点进退两难,希望大家能帮帮我。如你所见,我有一个AsyncTask我在其中保存了一些代码Bitmap将对象作为.jpg文件添加到图库中。在AsyncTask我也在使用Context,但据我所知,使用Activity的上下文在这个内部类中可能会导致内存泄漏,所以我将其更改为WeakReferenceweakContext;所以垃圾收集器可以收集它。但是通过使用Application我从传递的View中获得的上下文从构造函数我应该归档与弱上下文引用相同的效果那么在这种情况下使用哪个更好呢?publicclassViewToBitmap{privateViewview;privateWe

java - 将应用程序配置到 facebook 错误 : "App is misconfigured for Facebook login.."

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:AppismisconfiguredforFacebooklogin:AndroidFacebookintegrationissue我正在尝试将facebook集成到我的应用程序中。当我按下登录按钮并填写电子邮件和密码时,我在应用程序中收到一条错误消息:“AppismisconfiguredforFacebooklogin.."然后我必须按“确定”按钮然后它关闭。我已经在我的facebook应用程序中填写了这些字段,这是一张图片:此外,当我按下“登录”按钮(我创建的弹出facebook登录的按钮)时,在log

android - 使用 Context 获取 LayoutInflater

这两者有什么区别吗?inflater=(LayoutInflater)LayoutInflater.from(context);inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 最佳答案 目前还没有,正如您通过检查theLayoutInflatersourcecode可以看到的那样.from()将抛出一个Exception而不是返回null,但除此之外它们是相同的。就个人而言,我大部分时间都使用getLayoutIn

android - 构造函数 SimpleCursorAdapter(Context, int, Cursor, String[], int[]) 已弃用

如何解决这个问题?TheconstructorSimpleCursorAdapter(Context,int,Cursor,String[],int[])isdeprecated和ThemethodmanagedQuery(Uri,String[],String,String[],String)fromthetypeActivityisdeprecated代码如下:packagecom.example.kamusdigital;importandroid.app.Activity;importandroid.os.Bundle;importandroid.view.View;impor

android - 使用 Context.getText 和 Context.getResources.getText 有什么区别吗?

所以我注意到似乎有两种方法可以获取相同的数据,我不确定是否有关于何时应该使用其中任何一种的指南(除了绕过getResources可以节省内存,如果你实际上不想多次使用该对象)。但除此之外,我想知道是否有使用指南或理由Context.getText(id)与Context.getResources.getText(id)有人能帮忙吗? 最佳答案 没有区别。getText(id)的来源是:/***Returnalocalized,styledCharSequencefromtheapplication'spackage's*defaul

安卓 : Do Application Login in background on boot-up

我有一个VOIP应用程序,我需要在设备启动时在后台登录该应用程序。目前我的应用程序的初始化是在UIActive(onCreate())上完成的。我脑子里有以下事情,谁能帮我解开疑惑。服务设计必须要完成这个任务??哪个远程服务(AIDL)或本地服务?为什么?UI和Service交互是如何发生的?UI激活后,谁得到回调?UI还是Service?我是否应该将Service作为我的Controller,即Service到UI数据传递反之亦然?示例应用:Skype。 最佳答案 所以有很多方法可以实现你想要的,关键是什么更适合你的风格和设计。希