There is an activity in my android application which checks for the latest
version of app
on app's server. When it finds a new version of the app, it initiates a
download process of the apk file using DownloadManager. When activity
receives the message that the application is downloaded, it tries to open
the downloaded file. And when the apk file is opened, the installation
process is automatically started.
Here is the code of my BroadCastReceiver:
BroadcastReceiver broad= new BroadcastReceiver(){
@Override
public void onReceive(Context con,Intent inxc)
{String sact=inxc.getAction();
if(DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(sact))
{
Query qer=new Query();
qer.setFilterById(dloadid);
final Cursor curr=dloadm.query(qer);
if(curr.moveToFirst())
{int
cind=curr.getColumnIndex(DownloadManager.COLUMN_STATUS);
if(DownloadManager.STATUS_SUCCESSFUL==curr.getInt(cind))
{final AlertDialog instd=new
AlertDialog.Builder(fze).create();
instd.setTitle("Test app ");
instd.setMessage("New apk for
application Downloaded.\n Would you like to install it now");
instd.setButton(-1,"Yes",new
DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface
dface,int fox)
{/*EXCEPTION OCCURRED IN
FOLLOWING LINE*/
String
apkloc=curr.getString(curr.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME));
Intent installapk=new
Intent(Intent.ACTION_VIEW);
installapk.setDataAndType(Uri.fromFile(new File(apkloc)),
"application/vnd.android.package-archive");
startActivity(installapk);
}
});
instd.setButton(-3,"No", new
DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface
dface,int fox)
{
instd.dismiss();
}
});
instd.show();
}
}
}
}
};
**This code is working fine.**
But recently I received some users' feedback mentioning they received
"Unfortunately Activity Stopped..." message .
StackTrace
java.lang.IllegalArgumentException: Invalid column index -1, 12
columns exist
at
android.app.DownloadManager$CursorTranslator.getColumnName(DownloadManager.java:1261)
at
android.app.DownloadManager$CursorTranslator.getString(DownloadManager.java:1315)
at com.android.testdl.Fview$2$1.onClick(AppTest.java:146)
at
com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:165)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3691)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
at dalvik.system.NativeStart.main(Native Method)
Any suggestions?
All users who received this error messages were not on WI-FI connection.
They were on mobile network.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en