嗨,我需要有关陈述的帮助,在检查情况之前,它总是跳转到其他地方!我的代码:
@Override
public void onReceive(Context p1, Intent p2)
{
if ("android.intent.action.BOOT_COMPLETED".equals(p2.getAction())) {
Toast.makeText(p1, "Device is ON from Recever",Toast.LENGTH_LONG).show();
Intent starServiceIntent = new Intent(p1,MyService.class);
p1 .startService(starServiceIntent);
} @Override
public void onReceive(Context p1, Intent p2)
{
if ("android.intent.action.BOOT_COMPLETED".equals(p2.getAction())) {
Toast.makeText(p1, "Device is ON from Recever",Toast.LENGTH_LONG).show();
Intent starServiceIntent = new Intent(p1,MyService.class);
p1 .startService(starServiceIntent);
} if(state.equals(TelephonyManager.EXTRA_STATE_RINGING)){
SharedPreferences prefs = p1.getSharedPreferences("myPrefss", Context.MODE_PRIVATE);
if(!prefs.contains(incomingNumber)){
Toast.makeText(p1,"True",Toast.LENGTH_SHORT).show();
DateFormat timeFormat = new SimpleDateFormat("dd-MM-yy HH:mm");
timeFormat.setTimeZone(TimeZone.getTimeZone("Asia/Jerusalem"));
String curTime = timeFormat.format(new Date());
SharedPreferences.Editor editor = prefs.edit();
editor.putString(incomingNumber, curTime);
editor.commit();
sendSMS(incomingNumber,p1);
}else{
getStored(p1,incomingNumber);
Toast.makeText(p1,"False",Toast.LENGTH_SHORT).show();
}
}
//先给我假,然后给真,即使满足条件