Problem Starting New Activity

Put your problem here if it does not fit any of the other categories.

Problem Starting New Activity

Postby tbehr » Mon Mar 02, 2009 5:15 pm

Code: Select all
public class MyPhoneStateListener extends PhoneStateListener {
   
    final static String TAGTEXT = "DEBUG LISTENER!!!";
     boolean ringing = false;
     boolean offhook = false;
     
   
     
    @Override
   public void onCallStateChanged(int state,String incomingNumber){
      switch(state)
        {
     case TelephonyManager.CALL_STATE_IDLE:
          Log.d(TAGTEXT,"IDLE");       
          Log.d(TAGTEXT,"ringing "+ringing+" offhook "+offhook);
          if(ringing&&(!offhook))
          {
               Log.d(TAGTEXT, "You have missed a call");
                ringing = false;
                offhook = false;
             
              //problem
                Intent i = new Intent("com.bnet.detectmissedcall.SoundNotification");
                startActivity(i);
             //   
               
           
               
          break; }

     case TelephonyManager.CALL_STATE_RINGING:
          Log.d(TAGTEXT, "RINGING");
          ringing = true;
          offhook = false;

          break;
     case TelephonyManager.CALL_STATE_OFFHOOK:
          Log.d(TAGTEXT, "OFFHOOK");
          offhook = true;
          ringing = false;
          break;

     default:
                         
          break;
     }


      
    }

   
}
tbehr
Freshman
Freshman
 
Posts: 9
Joined: Wed Feb 18, 2009 5:03 pm
Location: Chicago

Top

Re: Problem Starting New Activity

Postby sarangkulkarni17 » Tue Mar 03, 2009 7:47 am

tbehr wrote:
Code: Select all
public class MyPhoneStateListener extends PhoneStateListener {
   
    final static String TAGTEXT = "DEBUG LISTENER!!!";
     boolean ringing = false;
     boolean offhook = false;
     
   
     
    @Override
   public void onCallStateChanged(int state,String incomingNumber){
      switch(state)
        {
     case TelephonyManager.CALL_STATE_IDLE:
          Log.d(TAGTEXT,"IDLE");       
          Log.d(TAGTEXT,"ringing "+ringing+" offhook "+offhook);
          if(ringing&&(!offhook))
          {
               Log.d(TAGTEXT, "You have missed a call");
                ringing = false;
                offhook = false;
             
              //problem
                Intent i = new Intent("com.bnet.detectmissedcall.SoundNotification");
                startActivity(i);
             //   
               
           
               
          break; }

     case TelephonyManager.CALL_STATE_RINGING:
          Log.d(TAGTEXT, "RINGING");
          ringing = true;
          offhook = false;

          break;
     case TelephonyManager.CALL_STATE_OFFHOOK:
          Log.d(TAGTEXT, "OFFHOOK");
          offhook = true;
          ringing = false;
          break;

     default:
                         
          break;
     }


      
    }

   
}


Hello tbehr,

For starting new activity you must use fallowing code

Intent i = new Intent();
i.putExtra("playername",playername);
setClass(eggcatch, Database.class);
startActivityForResult(i, ACTIVITY_CREATE);

you can send variables from one activity to another by putExtra()
& receive in another activity by
getIntent().getStringExtra(playername); if it is String
sarangkulkarni17
Developer
Developer
 
Posts: 29
Joined: Fri Feb 13, 2009 10:00 am
Location: Pune

Postby tbehr » Tue Mar 03, 2009 5:31 pm

Thanks. What if I'm simply calling a class to play a default sound. The error I'm getting is...method startActivity(Intent) is undefined for the type.
tbehr
Freshman
Freshman
 
Posts: 9
Joined: Wed Feb 18, 2009 5:03 pm
Location: Chicago

Postby sarangkulkarni17 » Wed Mar 04, 2009 7:04 am

tbehr wrote:Thanks. What if I'm simply calling a class to play a default sound. The error I'm getting is...method startActivity(Intent) is undefined for the type.


startActivity() belongs to Activity class you have to extend Activity class
sarangkulkarni17
Developer
Developer
 
Posts: 29
Joined: Fri Feb 13, 2009 10:00 am
Location: Pune

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 22 guests