Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old November 13th, 2011, 08:53 PM   #1 (permalink)
New Member
 
Join Date: Sep 2011
Posts: 4
 
Device(s):
Thanks: 1
Thanked 0 Times in 0 Posts
Footmouth My applications doesn't recall!

Hello!

I'm developing an application for old man that needs help. One feature of the application is the call-again function.

But the applications doesn't call again and I don't know why!

I have this code:

Code:
public class MainActivity extends Activity {

    TelephonyManager tm;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
        tm.listen(mPhoneListener, PhoneStateListener.LISTEN_CALL_STATE);
    }

    private void call() {
        try {
            startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:"
                    + "1111111")));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private PhoneStateListener mPhoneListener = new PhoneStateListener() {
        public void onCallStateChanged(int state, String incomingNumber) {
            try {
                switch (state) {
                case TelephonyManager.CALL_STATE_RINGING:
                    Toast.makeText(MainActivity.this, "CALL_STATE_RINGING",
                            Toast.LENGTH_SHORT).show();
                    break;
                case TelephonyManager.CALL_STATE_OFFHOOK:
                    Toast.makeText(MainActivity.this, "CALL_STATE_OFFHOOK",
                            Toast.LENGTH_SHORT).show();
                    break;
                case TelephonyManager.CALL_STATE_IDLE:
                    //(Trying) SystemClock.sleep(10000);
                    Toast.makeText(MainActivity.this, "CALL_STATE_IDLE",
                            Toast.LENGTH_SHORT).show(); // This is shown!
                    call(); // This doesn't call again !
                    break;
                default:
                    Toast.makeText(MainActivity.this, "default",
                            Toast.LENGTH_SHORT).show();
                    Log.i("Default", "Unknown phone state=" + state);
                }
            } catch (Exception e) {
                Log.i("Exception", "PhoneStateListener() e = " + e);
            }
        }
    };
}
Thank-you very very much!

Kanashin is offline  
Reply With Quote
Sponsors
Reply

Bookmarks

Tags
call


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 11:49 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo