上个月,我在 Google Play Console 上看到了本机崩溃的强劲高峰,它们来自三星设备,占 98%,主要是 Android 10 (90%),其次是 Android 9 (10%)。超过一半的案例与三星 S9 设备有关,而其余案例与最近的设备型号(三星 s10+、Note9 等)有关。
有堆栈跟踪:
#00 pc 0000000000083360 /apex/com.android.runtime/lib64/bionic/libc.so (abort+176)
#01 pc 0000000000008a74 /system/lib64/liblog.so (__android_log_assert+324)
#02 pc 00000000003fb0dc /system/lib64/libhwui.so (android::uirenderer::renderthread::EglManager::swapBuffers(android::uirenderer::renderthread::Frame const&, SkRect const&)+276)
#03 pc 00000000003fae4c /system/lib64/libhwui.so (android::uirenderer::skiapipeline::SkiaOpenGLPipeline::swapBuffers(android::uirenderer::renderthread::Frame const&, bool, SkRect const&, android::uirenderer::FrameInfo*, bool*)+92)
#04 pc 0000000000407c8c /system/lib64/libhwui.so (android::uirenderer::renderthread::CanvasContext::draw()+716)
#05 pc 0000000000406d38 /system/lib64/libhwui.so (_ZNSt3__110__function6__funcIZN7android10uirenderer12renderthread13DrawFrameTask11postAndWaitEvE3$_0NS_9allocatorIS6_EEFvvEEclEv$c303f2d2360db58ed70a2d0ac7ed911b+216)
#06 pc 0000000000417a44 /system/lib64/libhwui.so (android::uirenderer::WorkQueue::process()+228)
#07 pc 0000000000417770 /system/lib64/libhwui.so (android::uirenderer::renderthread::RenderThread::threadLoop()+80)
#08 pc 00000000000137a4 /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+284)
#09 pc 00000000000e3b14 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36)
#10 pc 0000000000085330 /apex/com.android.runtime/lib64/bionic/libc.so …Run Code Online (Sandbox Code Playgroud) 我已经阅读了有关Android Oreo背景执行限制的内容,并且明确指出BOOT_COMPLETED广播不会受到影响,但我无法让它在Android Oreo上运行.
首先,我正在编译SDK 27.其次,我在清单文件中声明了接收器:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<receiver
android:name="helpers.StartDetectionAtBoot"
android:label="StartDetectionAtBoot"
android:enabled="true"
android:exported="true">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
<!--For HTC devices-->
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
<!--For MIUI devices-->
<action android:name="android.intent.action.REBOOT"/>
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
然后就是接收器的实现,它也可以很简单:
public class StartDetectionAtBoot extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.i("test", "test");
Intent intent0 = new Intent( context, ActivityRecognitionService.class );
PendingIntent pendingIntent = PendingIntent.getService(context, 111, intent0, PendingIntent.FLAG_UPDATE_CURRENT);
ActivityRecognitionClient activityRecognitionClient = ActivityRecognition.getClient(context);
activityRecognitionClient.requestActivityUpdates(5000, pendingIntent);
}
}
Run Code Online (Sandbox Code Playgroud)
onReceive 方法未被调用,我将永远在Android Oreo设备/模拟器上获得logcat错误:
W/BroadcastQueue:不允许后台执行:接收Intent {act …
android broadcastreceiver android-background android-8.0-oreo
基本上我正在尝试按照Google文档进行一些Chrome扩展.我想在每次单击扩展按钮时注入脚本.到目前为止,这是我的表现:
{
"name": "Example",
"manifest_version": 2,
"version": "1.0",
"permissions": [
"tabs"
],
"description": "My Chrome extension.",
"browser_action": {
"default_icon": "icon.png"
},
"background": {
"scripts": ["background.js"]
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的background.js:
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(tab.id, {code: "content_script.js"});
});
Run Code Online (Sandbox Code Playgroud)
问题是即使尝试使用这么简单,也不会触发content_script alert("aaa");
你能告诉我我做错了什么吗?我无法弄清楚.
随着更新的Android Q的出现,许多事情发生了变化,尤其是在范围存储和file:///URI 逐渐弃用的情况下。问题是缺少有关如何在Android Q设备上正确处理媒体文件的文档。
我有一个媒体文件(音频)管理应用程序,但找不到一种可靠的方法来告诉OS我对文件进行了更改,以便它可以更新其MediaStore记录。
选项1:MediaScannerService
MediaScannerConnection.scanFile(context, new String[]{ filePath }, new String[]{"audio/*"}, new MediaScannerConnection.OnScanCompletedListener() {
@Override
public void onScanCompleted(String s, Uri uri) {
}
});
Run Code Online (Sandbox Code Playgroud)
file://主存储中的URIfile://辅助存储(例如可移动存储)中的URIcontent://URI选项2:广播
context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri));
Run Code Online (Sandbox Code Playgroud)
选项3:手动插入MediaStore
AudioFileContentValues是来自的某些列值MediaStore.Audio.AudioColumns。
基于file://URI的旧方法:
Uri uri = MediaStore.Audio.Media.getContentUriForPath(file_path);
newUri = context.getContentResolver().insert(uri, AudioFileContentValues);
Run Code Online (Sandbox Code Playgroud)
MediaStore.Audio.Media.getContentUriForPath 不推荐使用基于我可以从文档中得出的新方法:
Uri collection = MediaStore.Audio.Media.getContentUri(correctVolume);
newUri = context.getContentResolver().insert(collection, AudioFileContentValues);
Run Code Online (Sandbox Code Playgroud)
哪里correctVolume会external从主存储,同时它会是这样的0000-0000二级存储,根据该文件的位置。 …
android mediastore android-contentresolver android-external-storage android-10.0
我正在使用Java编写服务器 - 客户端应用程序,我需要在服务器端实现本地数据库,我决定使用H2数据库引擎.
还有一件事是我通过TCP连接来启动和运行数据库.这是我到目前为止所放在一起的:
Class.forName("org.h2.Driver");
Server server = Server.createTcpServer(DB_PATH).start();
Connection currentConn = DriverManager.getConnection(DB_PATH, DB_USER, DB_PASSWORD);
Run Code Online (Sandbox Code Playgroud)
连接字符串的位置jdbc:h2:tcp://localhost/~/test.
这段代码返回一个例外:
Feature not supported: "jdbc:h2:tcp://localhost/~/test" [50100-176]
Run Code Online (Sandbox Code Playgroud)
我跟着这篇文章.
我正在尝试显示设备上找到的歌曲列表,这些歌曲直接从MediaStore请求数据.我正在使用一个RecyclerView和一个使用a CursorAdapter来从MediaStore获取数据的适配器.onBindViewHolder调用适配器时,请求将传递给所有可视元素设置的bindView函数CursorAdapter.
public class ListRecyclerAdapter3 extends RecyclerView.Adapter<ListRecyclerAdapter3.SongViewHolder> {
// PATCH: Because RecyclerView.Adapter in its current form doesn't natively support
// cursors, we "wrap" a CursorAdapter that will do all teh job
// for us
public MediaStoreHelper mediaStoreHelper;
CustomCursorAdapter mCursorAdapter;
Context mContext;
public class SongViewHolder extends RecyclerView.ViewHolder {
public TextView textItemTitle;
public TextView textItemSub;
public ImageView imgArt;
public int position;
public String album_id;
public String path_art;
public String path_file;
public SongViewHolder(View v) …Run Code Online (Sandbox Code Playgroud) 我是php编程的新手.在我的项目中,我试图解析来自php web服务的JSON数据.这是Web服务中的代码.
$query = "select * from tableA where ID = 1";
$result = mysql_query($query);
if (mysql_num_rows($result) > 0) {
$arr= array();
while ($row = mysql_fetch_assoc($result)) {
$arr['articles'][] = $row;
}
header('Content-type: application/json');
echo json_encode($arr);
}
else{
echo "No Names";
}
Run Code Online (Sandbox Code Playgroud)
这给了我这种JSON格式的数据.
{"articles":[{"ID":"1","Title":"Welcome","Content":"This is the first article."}]}
Run Code Online (Sandbox Code Playgroud)
现在这是我的php页面代码.
<?php
$jfile = file_get_contents('http://localhost/api/get_content.php');
$final_res = json_decode($jfile, true) ;
var_dump( $final_res );
$content = $final_res->articles->Content;
?>
Run Code Online (Sandbox Code Playgroud)
我想在网页上显示内容.
我知道代码var_dump( $final_res );正在运行.但那段代码错了之后.我试图查看许多教程来找到解决方案,但没有找到任何人.我不知道我哪里错了.
android ×4
android-10.0 ×1
h2 ×1
java ×1
jdbc ×1
json ×1
mediastore ×1
php ×1
picasso ×1
scroll ×1