我已经SMS Retriever API在谷歌教程和我的调试Build Variant工作中实现了类似的工作.我可以读取短信并获取用户可以登录的代码.
我的问题是,当我在发布版本Variant中运行应用程序sms它不起作用.我收到了短信,但我无法读取代码进行登录.
我在发布模式下更改了AppSignatureHelper生成的哈希,该模式与调试模式不同.在调试工作和发布没有.
一些帮助将是欣赏
代码:
表现:
<receiver android:name=".app.receivers.SmsReceiver">
<intent-filter>
<action android:name="com.google.android.gms.auth.api.phone.SMS_RETRIEVED"/>
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
在我的类中:(在发布和调试模式下,代码将抛出onSucess方法)此方法在onCreate中调用.
private void startSMSListening(){
SmsRetrieverClient client = SmsRetriever.getClient(this);
Task<Void> task = client.startSmsRetriever();
task.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
// Successfully started retriever, expect broadcast intent
Log.e("startSMSListening", "listening sms");
sendCode();
showHideLoadingView(false);
}
});
task.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// Failed to start retriever, inspect Exception for more details
Log.e("startSMSListening", "failure listening …Run Code Online (Sandbox Code Playgroud) android android-intent android-broadcast android-broadcastreceiver android-sms
我刚刚将Android Studio更新3.2为3.3。它将我项目中的Gradle插件从更新3.2.1为3.3。现在启用高级分析,Run/Debug configuration使我的应用程序崩溃。Clean/Rebuild/Invalidate caches不要帮忙
我找到了一种使其工作的方法:将插件回滚到3.2.1(在build.gradle项目中)
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
Run Code Online (Sandbox Code Playgroud)
还有其他办法吗?
01-15 13:38:31.527 6969-6969/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.appcard.androidterminal, PID: 6969
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/android/tools/profiler/support/ProfilerService;
at com.appcard.androidterminal.AppContext.<init>(AppContext.java:53)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1606)
at android.app.Instrumentation.newApplication(Instrumentation.java:1000)
at android.app.Instrumentation.newApplication(Instrumentation.java:985)
at android.app.LoadedApk.makeApplication(LoadedApk.java:567)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4837)
at android.app.ActivityThread.access$1500(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1531)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5643)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.ClassNotFoundException: Didn't find …Run Code Online (Sandbox Code Playgroud) android profiling android-studio android-gradle-plugin gradle-plugin
(我在帖子底部添加了更新)
我目前正在开发一个支持多种语言的项目。我已经编写了所有语言的所有字符串。
我使用 BaseActivity、Application 类和 LocaleHelper 来管理应用程序上的本地化。然后我在我的应用程序上发现了这种行为。在我将Locale设置为另一种语言后,某些活动中的字符串被更改并正确,但在MainActivity中却没有,即使它们具有一些相同的字符串。我尝试重新启动应用程序,但它仍然无法正常工作。
我还有另一个活动,活动中的一些单词被翻译了,但片段和回收器视图中的所有单词根本没有被翻译。
我仍然找不到它翻译不正确的原因。有人能帮我吗??
这是一些片段:
应用类
@Override
public void onCreate() {
super.onCreate();
LocaleUtil.setLocale(new Locale(LocaleUtil.with(this).getPreference()));
LocaleUtil.updateConfig(this,getBaseContext().getResources().getConfiguration());
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
LocaleUtil.setLocale(new Locale(LocaleUtil.with(this).getPreference()));
LocaleUtil.updateConfig(this, newConfig);
}
Run Code Online (Sandbox Code Playgroud)
基础活动
public BaseActivity() {
LocaleUtil.updateConfig(this);
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
initLocale();
super.onCreate(savedInstanceState);
}
public void initLocale(){
localeUtil = new LocaleUtil(this);
localeUtil.setListener(this);
localeUtil.setLanguageByCode(localeUtil.getPreference());
}
Run Code Online (Sandbox Code Playgroud)
请帮我!谢谢!!
(更新)
我发现每当我想要访问Recyclerview 和片段中的任何视图的Strings.xml时,我都必须再次设置Locale。这完全不方便,而且我担心性能。我很想听到关于更改语言的更好建议。
我最近更新Android Studio 3.3并注意到我的布局预览分辨率较低。
有什么解决办法可以解决这个问题吗?此问题仅在预览和设计选项卡(不包括蓝图)中发生 - 运行应用程序没有问题。
谢谢
更新:我删除了所有 Android Studio 文件,包括 SDK(以某种方式安装在我的其他 SSD 上)。然后我重新下载Android Studio 3.3并打开我的项目,却发现问题仍然存在。
应用程序抛出此错误
Error Loading module com.google.android.gms.dynamite.DynamiteModule$LoadingException: No acceptable module found. Local version is 0 and remote version is 0
Run Code Online (Sandbox Code Playgroud)
在尝试配置 Google-vision FaceDetector 时,我目前正在使用'com.google.android.gms: play-services-base: 16.1.0'和'com.google.android.gms: play- services-vision: 17.0.2 ',在android 7.0 中,设备上的 google play 服务版本为14.7.99。
这是 logcat 输出:
2019-01-22 16:19:41.682 21333-21333/com.nowfloats.camera I/DynamiteModule: Considering local module com.google.android.gms.vision.dynamite.face:0 and remote module com.google.android.gms.vision.dynamite.face:0
2019-01-22 16:19:41.683 21333-21333/com.nowfloats.camera D/FaceNativeHandle: Cannot load feature, fall back to load whole module.
2019-01-22 16:19:41.684 21333-21333/com.nowfloats.camera W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.dynamite not …Run Code Online (Sandbox Code Playgroud) android.support.design.widget.TextInputLayout切换到 AndroidX 并启用后错误膨胀类style/Widget.MaterialComponents.TextInputLayout.OutlinedBox
朋友们大家好,今天我将我的项目切换到 Androidx(我需要的新库需要),并且我的TextInputLayout.
请注意,当我删除 OulinedBox 样式时,它可以完美编译,但我绝对需要这个项目。
有谁知道让 OulinedBox TextInputLayout 样式与 AndroidX 一起使用的方法?
非常感谢您的帮助和时间。
<android.support.design.widget.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="60dp"
android:layout_marginTop="20dp"
app:boxStrokeColor="@color/gradient_begin_purple">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/login"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud) 我正在尝试从 URL 解析 JSON 数据并将其显示在 listView 中,但出现此错误:
03-27 20:53:04.830 13960-14086/com.example.samplejson E/HttpHandler:IOException:无法解析主机“jsonplaceholder.typicode.com”:没有与主机名关联的地址
03-27 20:53:04.830 13960-14086/com.example.samplejson E/MainActivity:来自 url 的响应:空
03-27 20:53:04.830 13960-14086/com.example.samplejson E/MainActivity:无法从服务器获取 json。
我已经在我的androidmanifest.xml 中添加了这一行:
<uses-permission android:name="android.permission.INTERNET" />
Run Code Online (Sandbox Code Playgroud)
这是我的 MainActivity.java 文件:
public class MainActivity extends AppCompatActivity {
private String TAG = MainActivity.class.getSimpleName();
private ProgressDialog pDialog;
private ListView lv;
// URL to get contacts JSON
private static String url = "https://jsonplaceholder.typicode.com/users";
ArrayList<HashMap<String, String>> contactList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
contactList = new ArrayList<>();
lv = (ListView) findViewById(R.id.listview); …Run Code Online (Sandbox Code Playgroud) android ×7
android-sms ×1
androidx ×1
java ×1
json ×1
localization ×1
preview ×1
profiling ×1
string ×1
vision ×1