0

我收到以下错误。请告诉我如何删除此错误。由于我的应用程序中的 Toast,我收到此错误。如果我删除这个吐司一切正常。请帮助我。

日志猫:

08-17 20:12:23.753: E/(7381): file /data/data/com.nvidia.NvCPLSvc/files/driverlist.txt:  not found!
08-17 20:12:23.753: I/(7381): Attempting to load EGL implementation /system/lib//egl/libEGL_tegra_impl
08-17 20:12:23.758: I/(7381): Loaded EGL implementation /system/lib//egl/libEGL_tegra_impl
08-17 20:12:23.793: I/(7381): Loading GLESv2 implementation /system/lib//egl/libGLESv2_tegra_impl

我正在测试htc1x。

这是我使用 Toast 的完整方法

public long putvalues(String event_name,String event_date,String event_time,String event_location){


    String anArray[] = new String[] {Column_Id,name,date,time,location};
    Log.d("in is duplicate","ere");
    Cursor c = ourSQLiteDatabase.query(Table_Name, anArray,name+" =?"+" AND "+date+" =?"+" AND "+time+" =?"+" AND "+location+" =?" ,
            new String[] {event_name,event_date,event_time,event_location}, null, null, null);

    if(c != null){
        Log.d("in if","in if");
        Toast.makeText(getBaseContext(), "already exist",Toast.LENGTH_SHORT).show();

    } 
ContentValues cv = new ContentValues();
    cv.put(name, event_name);
    cv.put(date, event_date);
    cv.put(time, event_time);
    cv.put(location, event_location);
    Log.d("in reminder", "put values1");
    return ourSQLiteDatabase.insert(Table_Name, null, cv);  
}
4

2 回答 2

1

不要使用getBaseContext(). 改用就好this了。

如果您要显示 a Toastfrom a Service,请使用getApplicationContext().

于 2013-08-17T15:08:16.810 回答
0

嘿你应该使用这个代码:

Toast.makeText(getApplicationContext(), "already exist",Toast.LENGTH_SHORT).show();
于 2013-08-17T15:20:28.877 回答