If you are having a pain in the ass getting this to work. Download the example from here
http://www.ziddu.com/download/17996784/preference_icon_example.zip.html
· Project A import project B and Project B import Project A .
private boolean getMobileDataEnabled() {
try {
Method method = connectivityManager.getClass().getMethod("getMobileDataEnabled");
return (Boolean)method.invoke(connectivityManager);
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
private void setMobileDataEnabled(boolean on) {
try {
Method method = connectivityManager.getClass().getMethod("setMobileDataEnabled",
boolean.class);
method.invoke(connectivityManager, on);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
.link0 2 C:/Aruna/Android/android-sdk_r08-windows/android-sdk-windows/Cupcake .link1 2 C:/Aruna/Android/android-sdk_r08-windows/android-sdk-windows/Donut
java.lang.IllegalStateException: Couldn't init cursor window at android.database.CursorWindow.native_init(Native Method) at android.database.CursorWindow.After few hours of googling, I found the solution to this problem. Solution is to close the Cursor after after you are done!This exception is thrown here(CursorWindow.java:41) at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:277) at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:269)
localOnly is defined inif (!window->initBuffer(localOnly)) { jniThrowException(env, "java/lang/IllegalStateException", "Couldn't init cursor window"); delete window; return; }
CursorWindow.has
#define MAX_WINDOW_SIZE (1024 * 1024)So, There are two possible causes to throw this exception. 1. Your mobile phone is out of memory.2. You are fetching something out of the database more than 1M. If there is a logical way to divide your queries into discrete chunks, you could do incremental queries and use CursorJoiner to stitch them together that might help you if you are dealing with big chuck of data.
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Object[] aPDUArray = (Object[]) bundle.get("pdus");
String pduString = toHexString((byte[]) aPDUArray[0]);
}
private final static char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F' };
public static String toHexString(byte[] array) {
int length = array.length;
char[] buf = new char[length * 2];
int bufIndex = 0;
for (int i = 0 ; i < length; i++)
{
byte b = array[i];
buf[bufIndex++] = HEX_DIGITS[(b >>> 4) & 0x0F];
buf[bufIndex++] = HEX_DIGITS[b & 0x0F];
}
return new String(buf);
}