我有一个broadcastreceiver.class
public class Myclass extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
}
}
我想在broadcastreceiver中调用函数,这是我的活动。请告诉我一些代码如何在这里做我的活动
public class MainActivity extends AppCompatActivity {
Context context = this;
private AudioManager myAudioManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
public void myfunction()
{
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(getApplicationContext(),com.example.faisal.wifiprofile.MainActivity.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
handler.postDelayed(this, 100000);
}
}, 100000);
}
}
}
这里是函数名myfunction我想在broadcastreceiver中调用这个函数请事先告诉我好的解决方案或编辑我的代码
答案 0 :(得分:0)
这应该有效:
SELECT m.*,
CASE
WHEN m.fromid = $id THEN m.from_status
WHEN m.toid = $id THEN m.to_status
END as read_status
FROM message m
WHERE
m.fromid = $id OR m.toid = $id
ORDER BY timestamp DESC;
}
public class Myclass extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
MainActivity.myfunction();
}
}