我想在模拟器中使用Action BOOT_COMPLETED检查BROADCAST RECEIVER。
这是我的代码
public class AutoRunService extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Toast.makeText(UApplication.getInstance(), "Application is ready to open ", Toast.LENGTH_SHORT).show();
myFunciton(context);
}
}
public void myFunciton(Context context) {
}
}
<receiver
android:name=".AutoRunService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
我使用的是Windows 10和genymotion模拟器。 有没有办法在模拟器中检查广播接收器?如何重新启动模拟器来检查接收器?有没有直接命令?
提前致谢。
答案 0 :(得分:1)
转到adb工具 - &gt;转到adb shell并使用以下命令
var express = require('express');
var dotenv = require('dotenv');
dotenv.load();
var designtokenfile= require ('./designtokenfile.js');
var designtokendb = require ('./designtokendb.js');
var DesignFactory = require('./DesignFactory.js');
var app = express();
var fs = require('fs');
var file = __dirname + '/edit0.json';
app.get('/Tokens', function(req, res) {
var store=DesignFactory.storeDesign(ex);
console.log(store);
var data=store.load();
res.end(data);
});
app.listen(3001);
console.log('Listening on port 3001...');
var ex=process.env.TYPE;
console.log(ex);
答案 1 :(得分:0)
只需将调试日志放入onRecieve()回调中,如下所示:
public class AutoRunService extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Log.d("Boot", "completed"); // log to make sure that boot completed action is received
}
}
要重新启动模拟器,请参阅以下答案: