我的app数据库类
@Database(entities = {Detail.class}, version = Constant.DATABASE_VERSION)
public abstract class AppDatabase extends RoomDatabase {
private static AppDatabase INSTANCE;
public abstract FavoritesDao favoritesDao();
public static AppDatabase getAppDatabase(Context context) {
if (INSTANCE == null) {
INSTANCE =
Room.databaseBuilder(context.getApplicationContext(), AppDatabase.class, Constant.DATABASE).allowMainThreadQueries().build();
//Room.inMemoryDatabaseBuilder(context.getApplicationContext(),AppDatabase.class).allowMainThreadQueries().build();
}
return INSTANCE;
}
public static void destroyInstance() {
INSTANCE = null;
}
}
Run Code Online (Sandbox Code Playgroud)
Gradle lib:
compile "android.arch.persistence.room:runtime:+"
annotationProcessor "android.arch.persistence.room:compiler:+"
Run Code Online (Sandbox Code Playgroud)
当我要求例如它会给出这个错误时,我的应用程序类中不存在AppDatabase_Impl
public class APp extends Application {
private boolean appRunning = false;
@Override
public void onCreate() {
super.onCreate();
AppDatabase.getAppDatabase(this); //--AppDatabase_Impl does …Run Code Online (Sandbox Code Playgroud) 我使用firebase ml kit进行文本识别,但在仿真器和真实设备上给出了这个例外.
W/System.err: com.google.firebase.ml.common.FirebaseMLException: Waiting for the text recognition model to be downloaded. Please wait.
at com.google.android.gms.internal.firebase_ml.zzjz.zzc(Unknown Source)
at com.google.android.gms.internal.firebase_ml.zzjz.zza(Unknown Source)
at com.google.android.gms.internal.firebase_ml.zzic.call(Unknown Source)
at com.google.android.gms.internal.firebase_ml.zzhx.zza(Unknown Source)
at com.google.android.gms.internal.firebase_ml.zzhy.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.google.android.gms.internal.firebase_ml.zze.dispatchMessage(Unknown Source)
at android.os.Looper.loop(Looper.java:136)
at android.os.HandlerThread.run(HandlerThread.java:61)
Run Code Online (Sandbox Code Playgroud)
在这里我的代码
private fun MlProcessText(imageUri:Uri) {
val bitmap = MediaStore.Images.Media.getBitmap(contentResolver, imageUri)
val textVision = FirebaseVisionImage.fromBitmap(bitmap)
val detector = FirebaseVision.getInstance().onDeviceTextRecognizer
detector.processImage(textVision).addOnSuccessListener { it ->
val blocks = it.textBlocks
if (blocks.size == 0 ){
tvVision.text = "NO TEXT"
}else{
blocks.forEach { …Run Code Online (Sandbox Code Playgroud) 我有一个活动,当设备在横向时从浏览器打开让我低于错误
java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
Run Code Online (Sandbox Code Playgroud)
表现
<activity android:name=".Activity.MyActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.Theme_Slide"
>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="xxx"
android:scheme="xxx" />
<data
android:host="xxx"
android:scheme="xxx" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
style.xml
<style name="AppTheme.Theme_Slide" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowCloseOnTouchOutside">false</item>
</style>
Run Code Online (Sandbox Code Playgroud) 我有两个活动,A和B. A调用了B startActivityForResult().B有主题@android:style/Theme.Dialog.
因此,B显示在"A"之上,但A仍然可见(因为B是对话框).
当两个活动都启动时,我通过切换到另一个任务并返回来强制重新创建(我在android开发人员设置中启用了"不要保持活动"选项.当我返回到我的任务时,我看到在A和B上调用OnCreate .)
当我点击活动B按钮,它调用setResult()和finish(),但onActivityResult() 不叫上.
问题没有出现
要么
我在使用Android 9的Google Pixel上测试了这个.
这是预期的行为还是Android中的错误?
这是我用来测试它的代码(Xamarin Android):
[Activity(Label = "@string/app_name")]
public class ActivityA : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
Kp2aLog.Log("OnCreate A");
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.yubichall_test);
{
FindViewById<Button>(Resource.Id.btn_yubichall).Text = "Start B";
FindViewById<Button>(Resource.Id.btn_yubichall).Click += (sender, args) =>
{
var chalIntent = new Intent(this, typeof(ActivityB));
StartActivityForResult(chalIntent, 123);
};
}
}
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, …Run Code Online (Sandbox Code Playgroud) setDefaults 在Android O及更高版本(SDK> = 26)中,Notification.Builder中的版本已弃用
也 setSound
这是我的代码
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
b.setAutoCancel(true)
.setSmallIcon(R.drawable.ic_luncher_new)
.setContentTitle(Title)
.setTicker(Title)
.setContentText(Msg)
.setChannelId("cid")
.setDefaults(Notification.DEFAULT_ALL)
.setStyle(new Notification.BigTextStyle().bigText(Msg))
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setContentIntent(contentIntent);
}
NotificationManager notificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationManager.createNotificationChannel(mChannel);
}
notificationManager.notify(id, b.build());`
Run Code Online (Sandbox Code Playgroud)
我应该更换什么?我找不到任何有用的例子