Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Urgent help on retrieving Outgoing Number

Urgent help on retrieving Outgoing Number

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

Urgent help on retrieving Outgoing Number

Postby hasitharandika » Sun May 02, 2010 11:17 am

hi guys,

i found a method which will return the outgoing number. but
found a issue about the method which finds out the Outgoing
Number. the issue is assume that i have dialed 12345 first. the method
returns the number accurately. but if i dialed 456789 after that
again the method returns the number as 12345.

and if i dialed another number for the third time then the method will
return 456789 as the number.

to have a clear view below is my code.

this is a very urgent case your quick response is really appriciated.



Code: Select all

package com.sabretch.mobility.coloreyed.callerview1.listener;

import java.text.BreakIterator;

import com.sabretch.mobility.coloreyed.callerview1.AnimationView;
import com.sabretch.mobility.coloreyed.callerview1.outgoing.OutGoing;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.provider.BaseColumns;
import android.provider.CallLog;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;

public class CallListener extends BroadcastReceiver {
        private Context context;
        // Intent intentttt = null;
        String phonenbr;

        @Override
        public void onReceive(Context context, Intent intent) {
                // TODO Auto-generated method stub
                this.context = context;
                TelephonyManager telManager = (TelephonyManager) context
                                .getSystemService(Context.TELEPHONY_SERVICE);
                telManager.listen(new StateListener(),
                                PhoneStateListener.LISTEN_CALL_STATE);

        }

        class StateListener extends PhoneStateListener {
                @Override
                public void onCallStateChanged(int state, String incomingNumber) {
                        // TODO Auto-generated method stub
                        // super.onCallStateChanged(state, incomingNumber);
                        switch (state) {
                        case TelephonyManager.CALL_STATE_RINGING:
                                Log.d("DEBUG", "RINGING");
                                break;
                        case TelephonyManager.CALL_STATE_IDLE:
                                //BroadcastReceiver.this.clearAbortBroadcast();
                                //context.unregisterReceiver(this.);
                                System.exit(0);
                                break;
                        case TelephonyManager.CALL_STATE_OFFHOOK:
                                phonenbr = getLastCallLogEntry(context);
                                break;
                        }
                }
        }

        private String getLastCallLogEntry(Context context) {
                String[] projection = new String[] { BaseColumns._ID,
                                CallLog.Calls.NUMBER, CallLog.Calls.TYPE };
                ContentResolver resolver = context.getContentResolver();
                Cursor cur = resolver.query(CallLog.Calls.CONTENT_URI, projection,
                                null, null, CallLog.Calls.DEFAULT_SORT_ORDER);
                int numberColumn = cur.getColumnIndex(CallLog.Calls.NUMBER);
                int typeColumn = cur.getColumnIndex(CallLog.Calls.TYPE);

                if (!cur.moveToNext()) {
                        cur.close();
                        return "";
                }
                String number = cur.getString(numberColumn);
                String type = cur.getString(typeColumn);
                String dir = null;
                try {
                        int dircode = Integer.parseInt(type);
                        switch (dircode) {
                        case CallLog.Calls.OUTGOING_TYPE:
                                dir = "OUTGOING";
                                break;

                        case CallLog.Calls.INCOMING_TYPE:
                                dir = "INCOMING";
                                break;

                        case CallLog.Calls.MISSED_TYPE:
                                dir = "MISSED";
                                break;
                        }
                } catch (NumberFormatException ex) {
                }
                if (dir == null)
                        dir = "Unknown, code: " + type;
                cur.close();
                return number;

        }

}





regards,
Randika
hasitharandika
Developer
Developer
 
Posts: 45
Joined: Mon Feb 15, 2010 8:37 am
Location: Sri Lanka

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 12 guests