我是android新手,我正在创建呼叫阻止应用程序。在这里,我编写了一个代码,可以更新Emulater中的调用日志,但是相同的代码在samsung mobile v2.2和其他android中都不起作用。
这是我的代码:
public int changeCallLog(String Pnum, Context ct)
{
long Phonenumber=Long.parseLong(Pnum);
int k=0;
try
{
Uri allCalls = Uri.parse("content://call_log/calls");
//Log.d("query 1", "Working , number going to update =>"+Phonenumber);
Cursor c = ct.getContentResolver().query(allCalls, null, "number="+Phonenumber, null, null);
c.moveToFirst();
//Log.d("query 2", "manage Cursor size="+c.getCount());
if(c.getCount()>0)
{
ContentValues values=new ContentValues();
//values.put("name", c.getString(c.getColumnIndex(Calls.CACHED_NAME))+"(X)");
values.put("number", c.getLong(c.getColumnIndex(Calls.NUMBER))+" (X)");
k=ct.getContentResolver().update(Uri.parse("content://call_log/calls"),values,"number="+Phonenumber,null);
Log.d("Query 3", "k="+k+", Name="+values);
}
}
catch (Exception e)
{
Toast.makeText(ct, ""+e, Toast.LENGTH_LONG).show();
Log.d("ResultActivitForCall", "Exception="+e);
}
return k;
}
请帮我解决这个问题。