Accessing CallLog beyond Activity

by Manfred » Sun, 15 Mar 2009 02:46:32 GMT


Sponsored Links
 Hi!

I want to get informed in a service about outgoing calls! As far as i
have seen its only possible with the CallLog. I found an example like
this:

          Cursor c = getContentResolver().query(
                    android.provider.CallLog.Calls.CONTENT_URI,
                    null, null, null,
                    android.provider.CallLog.Calls.DATE + " DESC");
          startManagingCursor(c);

The problem is, that i cannot invoke getContentResolver because the
class i want to use doesnt provide it. I found out that you need a
class that excents Activity to use this construct. Is it also possible
in another way?

Thanks
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Problem in converting byte array in Bitmap.

Hello,
I want to store image in sqlite database.
I tried to store it using BLOB and String, in both cases it store the
image and can retrieve it but when  i convert it to Bitmap using
BitmapFactory.decodeByteArray(...) it return null.
Below is my code please have a look and suggest me where i m making
mistake.

public class imagesql extends Activity {
    /** Called when the activity is first created. */

        Bitmap bi=null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        InputStream in=this.getResources().openRawResource
(R.drawable.dig);
        bi  = BitmapFactory.decodeStream(in);
        Log.i("bitmap1",""+bi);
        ImageView iv1=(ImageView)findViewById(R.id.img1);
        iv1.setImageBitmap(bi);


        String str= convertBitmapToString(bi);
        Log.i("image string",str);
        myDB a=new myDB(this);
        a.open();
        a.insertTag(str);

        Cursor c=a.fetchData(myDB.TABLE_NAME_TAG,new String[]
{myDB.KEY_TAG_IMG},null,null);
        startManagingCursor(c);
        int rc=c.getCount();

        ImageView iv;
        c.moveToFirst();

        if(rc!=0)
        {
                String s=c.getString(0);
                Log.i("cursor string image",s);
                Bitmap bitmap=getBitMapFromString(s);
                Log.i("bitmap2",""+bitmap);
                 iv=(ImageView)findViewById(R.id.img);
                 iv.setImageBitmap(bitmap);
        }
    }

    public static String convertBitmapToString(Bitmap src)
    {
    ByteArrayOutputStream os=new ByteArrayOutputStream();
    src.compress(android.graphics.Bitmap.CompressFormat.PNG, 100,
(OutputStream) os);
    return os.toString();
    }

    public static Bitmap getBitMapFromString(String src)
    {
        Log.i("b=",""+src.getBytes().length);//returns 12111 as a length.
    return BitmapFactory.decodeByteArray(src.getBytes(),0,src.getBytes
().length);
    }

}

--~--~---------~--~----~------------~-------~--~----~

2. Poll: Application Upgrade Policies

I'd like to poll the community of developers about your thought on upgrades
for free applications, as we have to make this decision at SlideME as well.
Good idea? Bad? Would you like to see time-based (x number of days for
upgrades), version based (major upgrades, not free; but minor ones free)? Or
is the current Android Market way of handling okay for you?

Shane

--~--~---------~--~----~------------~-------~--~----~

3. Supporting more than one sensor device.

4. how to get selected indexof a listview (urgent plz)

5. how to get the current matrix mode

6. In Android can appl send laocation data as MMS or sms?

7. Persistent Sockets on ADP 1.1 (was Jetty Comet Library)