2012-04-23 4 views
1

ロックされているときに私のアラームが私のデバイスを起きさせる必要があります ロックされているときにこのアラームがデバイスを起動させる方法を教えてくださいコードはそれがロックがかかっているときにこのアラームがデバイスを起動させる方法

が、これは任意のヘルプは、事前にそれを 感謝を感謝します私のコード

// Alert Code 
    final AlertDialog alertDialog = new AlertDialog.Builder(this).create(); 
    alertDialog.setTitle("confirmation"); 
    alertDialog.setMessage("r u sure u wanna send it"); 

    // Timer Code 
    pendingIntent = PendingIntent.getService(CreateNewForm_3.this, 0, 
      new Intent(CreateNewForm_3.this, MyAlarmService.class), 0); 
    Send.setOnClickListener(new View.OnClickListener() { 

     public void onClick(View v) { 
      // TODO Auto-generated method stub 
      alertDialog.setButton("yes", 
        new DialogInterface.OnClickListener() { 
         public void onClick(DialogInterface dialog, 
           int which) { 
          // -1- InshaAllah we've to send the Case info. 
          // here MMS 
          String FullCaseMsg = "name: " + case1.getName() + "$" 
            + " gender: " + case1.getGender() + "$" 
            + " Age: " + case1.getAge() + "$" 
            + " clothes: " + case1.getClothes() 
            + "$" + " MoreInfo: " 
            + case1.getMoreInfo() + "$" + " time: " 
            + case1.getTime() + "$" + " loc: " 
            + case1.getLocation() + "$"; 
          // -2- then show toast 
          Toast.makeText(CreateNewForm_3.this, "sent ", 0) 
            .show(); 
          // test 

          // -3- starting timer 
          long firstTime = SystemClock.elapsedRealtime(); 
          am = (AlarmManager) getSystemService(ALARM_SERVICE); 
          am.setRepeating(
            AlarmManager.ELAPSED_REALTIME_WAKEUP, 
            firstTime + 10 * 1000, 30 * 1000, 
            pendingIntent); 
          // firstTime Will be the current_time + (10 * 
          // 60 * 1000) =) 
          // 10* 1000 will be (10 * 60 * 1000) 
          new Handler().postDelayed(new Runnable() { 
           public void run() { 
            bCancel.performClick(); 
           } 
          }, (30 * 1000)); 
          // (30 * 1000) will be firstTime + (2- 
          // duration) 

          /*Intent toRecentCases = new Intent(
            CreateNewForm_3.this, LMPActivity.class); 
          startActivity(toRecentCases);*/ 


          //4-add my case object to list View 
         //All_Static.MyCaseList.add(case1); 




         } 
        }); 

      alertDialog.setButton2("no", 
        new DialogInterface.OnClickListener() { 
         public void onClick(DialogInterface dialog, 
           int which) { 
          // here you can add functions 

         } 
        }); 

      alertDialog.setIcon(android.R.drawable.ic_dialog_alert); 
      alertDialog.show(); 
     } 

    }); 

    bCancel.setOnClickListener(new View.OnClickListener() { 

     public void onClick(View v) { 
      // TODO Auto-generated method stub 
      am.cancel(pendingIntent); 
     } 
    }); 

で、動作しませんでした

答えて

0

「AlarmManager.ELAPSED_REALTIME_WAKEUP」はデバイスをウェイクアップしたときにそのオフ、 けど私はドンデバイスの「ロックを解除」する(ピンやパターンを付ける)機会があると考えています。セキュリティ上の問題です。 (私が間違っていれば私を修正しなさい...)。

+0

コードを入力してください。ありがとうございます – Maha

+0

私はAlarmManager.ELAPSED_REALTIME_WAKEUPのコードを意味しますか?また、私は電話のロックを解除することを意味するものではありませんが、SMSのようにライトを開く – Maha

関連する問題