我正在尝试序列化我的位置类(使用android.location类)
但是,它给了我一个错误!
11-21 21:25:37.337: W/System.err(3152): java.io.NotSerializableException: android.location
Run Code Online (Sandbox Code Playgroud)
所以,我试图扩展android.location.Location课程.
private class NewLocation extends Location implements Serializable {
private String Provider;
private double Latitude, Longitude, Altitude;
private float bear;
public NewLocation(Location l) {
super(l);
Provider = l.getProvider();
Latitude = l.getLatitude();
Longitude = l.getLongitude();
Altitude = l.getAltitude();
bear = l.getBearing();
}
}
Run Code Online (Sandbox Code Playgroud)
之后,我试图序列化扩展类,但同样的错误.
这是序列化代码
public static byte[] serialize(Object obj) throws IOException {
ByteArrayOutputStream bao = new ByteArrayOutputStream();
ObjectOutput oos = new ObjectOutputStream(bao);
byte[] data = null;
oos.writeObject(obj);
oos.flush();
oos.close();
data = …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Google 的架构组件.具体来说,我想实现一个ViewModelProvider.Factory来创建一个带有构造函数参数的ViewModel,如下所示:
class MyFactory(val handler: Handler) : ViewModelProvider.Factory {
override fun <T : ViewModel?> create(modelClass: Class<T>?): T {
return MyViewModel(handler) as T
}
}
Run Code Online (Sandbox Code Playgroud)
我的ViewModel看起来像这样:
class MyViewModel(val handler: Handler) : ViewModel()
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何避免最后的讨厌演员:
return MyViewModel(handler) as T
Run Code Online (Sandbox Code Playgroud) 考虑这个简单的 Firestore 数据库结构:
1:Firestore结构
cities/
city1/
name:Beijing
likes: 0
dislikes: 0
... more fields
city2/
name: New York
likes: 21
dislikes: 1
... more fields
Run Code Online (Sandbox Code Playgroud)
为了保护数据库免受意外操作,我添加了以下 Firestore 安全规则
2 Firestore 安全规则:
// Allow read/write access to all users under any conditions
service cloud.firestore {
match /databases/{database}/documents {
match /cities/{cityId} {
allow read: if request.auth.uid != null;
allow update: if request.auth.uid != null &&
request.resource.data.keys().hasOnly(["likes", "dislikes"]);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这基本上允许我执行这些要求:
问题
为什么Exception: PERMISSION_DENIED: Missing or insufficient permissions.当我尝试使用 …
我正在尝试动态功能和Instant Apps。为了在各种功能之间导航,我使用了深层链接。
每次导航到另一个“活动”时,都会看到消歧对话框少于1秒,其中列出了1个应用程序。请注意,“ Once”和“ Always”(在荷兰语中)的选项是如何变灰的。
示例Github项目
我创建了一个简约的示例,该示例与我在Github上的当前结构相匹配。需要Android Studio 3.5-RC2
一些上下文:
我非常有信心,深层链接配置正确。但是由于你们还是想检查一下,因此配置如下:
1-清单:
<activity
android:name=".ProfileActivity">
<intent-filter
android:autoVerify="true"
android:priority="100">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="giddy.entreco.nl"
android:pathPrefix="/profile"
android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
2-Assetlinks 我的域包含一个可公开访问的assetlinks.json
3-Sha's正确 我使用的sha's正确
Executing tasks: [signingReport] in project
SHA1: 3A:52:19:77:C1:AD:18:F4:98:21:77:74:37:DC:9B:89:02:64:6E:C6
SHA-256: 25:DD:C3:7B:8E:35:D3:39:D5:D4:6C:B5:EA:7D:14:AF:82:EC:9C:56:A6:F5:76:A3:E1:D7:69:B3:EC:58:72:E8
Valid until: Saturday, March 21, 2048
Run Code Online (Sandbox Code Playgroud)
4-确认的数字资产链接文件 所有检查均通过 https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://giddy.entreco.nl&relation=delegate_permission/common.handle_all_urls
5-测试URL意图 也可以!唯一的问题是我在短时间内看到了消歧对话框。
附加信息
我apply plugin: 'com.android.dynamic-feature'在所有模块中使用(app当然课程除外)
Android Studio:3.5 RC2;Android-gradle-plugin:3.5.0-rc02
我的设备是OnePlus6-配备氧气9.0.7和Android 9
android android-manifest android-instant-apps android-app-bundle android-app-links
我有一个应用程序,它下载一个zip并解压缩我SDCard上的文件.一切正常,但是当我的同事在他的Mac(狮子)上创建zip文件时,我的所有文件都有
大小:-1
CRC:-1
compressedsize:-1
我无法将文件写入我的SD卡.两个拉链具有完全相同的内容,唯一的区别在于它们最初压缩的位置.这是我解压缩文件的代码:
public class UnzipTask extends AsyncTask<String, Integer, Void> {
private static final String TAG = UnzipTask.class.getSimpleName();
private String mDestLocation;
private ZipListener mListener;
private Context mCtx;
private int mCallbackId;
public UnzipTask(Context context, ZipListener listener, File dir)
{
mCtx = context;
mListener = listener;
mDestLocation = dir.getAbsolutePath() + "/";
}
public void setId(int id)
{
mCallbackId = id;
}
@Override
protected Void doInBackground(String... arg0) {
try {
String file = arg0[0];
InputStream is = mCtx.getAssets().open(file);
unzipFile(is);
} catch …Run Code Online (Sandbox Code Playgroud)