I am a novice at android development. I have to show a PDF from a URL.
This is my current code but I'm not able to show the PDF file:
public class TestActivity extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
System.setProperty("http.proxyHost","192.168.0.2");
System.setProperty("http.proxyPort","8080");
showPdf();
}
private void showPdf()
{
WebView webview = new WebView(this);
setContentView(webview);
webview.getSettings().setJavaScriptEnabled(true);
Log.v("....hello....","");
webview.loadUrl("http://docs.google.com/gview?embedded=true&url=http://myurl.com/demo.pdf");
}
}
Logcat:
10-11 14:50:49.586: ERROR/AndroidRuntime(537): FATAL EXCEPTION: main
10-11 14:50:49.586: ERROR/AndroidRuntime(537): android.app.SuperNotCalledException: Activity {com.vidushi.Test/com.vidushi.Test.TestActivity} did not call through to super.onCreate()
10-11 14:50:49.586: ERROR/AndroidRuntime(537): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2629)
10-11 14:50:49.586: ERROR/AndroidRuntime(537): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
10-11 14:50:49.586: ERROR/AndroidRuntime(537): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
10-11 14:50:49.586: ERROR/AndroidRuntime(537): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
10-11 14:50:49.586: ERROR/AndroidRuntime(537): at android.os.Handler.dispatchMessage(Handler.java:99)
10-11 14:50:49.586: ERROR/AndroidRuntime(537): at android.os.Looper.loop(Looper.java:123)
10-11 14:50:49.586: ERROR/AndroidRuntime(537): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-11 14:50:49.586: ERROR/AndroidRuntime(537): at java.lang.reflect.Method.invokeNative(Native Method)
10-11 14:50:49.586: ERROR/AndroidRuntime(537): at java.lang.reflect.Method.invoke(Method.java:521)
10-11 14:50:49.586: ERROR/AndroidRuntime(537): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-11 14:50:49.586: ERROR/AndroidRuntime(537): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-11 14:50:49.586: ERROR/AndroidRuntime(537): at dalvik.system.NativeStart.main(Native Method)
Its working fine here. Still let me suggest you to test whether you have added INTERNET permission in AndroidManifest.xml file or not:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
Update:
The link you want to open is: http://litofinter.es.milfoil.arvixe.com/PDF/Book6.pdf
Now its also working fine here:
Related
The app is bloked only in last release test (Play Store) with:
google Pixel 5
1080x2340
Android 11 (SDK 30)
8.192 MB
arm64-v8a
es_ES
Before, in compilation with android studio all is ok.
This is the crash in google play release test with GooglePixel:
10-11 05:34:40.895: D/AndroidRuntime(22146): Shutting down VM
10-11 05:34:40.895: D/AndroidRuntime(22146): --------- beginning of crash
10-11 05:34:40.895: E/AndroidRuntime(22146): FATAL EXCEPTION: main
10-11 05:34:40.895: E/AndroidRuntime(22146): Process: com.google.android.gms.persistent, PID: 22146
10-11 05:34:40.895: E/AndroidRuntime(22146): android.app.RemoteServiceException: can't deliver broadcast
10-11 05:34:40.895: E/AndroidRuntime(22146): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2005)
10-11 05:34:40.895: E/AndroidRuntime(22146): at android.os.Handler.dispatchMessage(Handler.java:106)
10-11 05:34:40.895: E/AndroidRuntime(22146): at android.os.Looper.loop(Looper.java:223)
10-11 05:34:40.895: E/AndroidRuntime(22146): at android.app.ActivityThread.main(ActivityThread.java:7664)
10-11 05:34:40.895: E/AndroidRuntime(22146): at java.lang.reflect.Method.invoke(Native Method)
10-11 05:34:40.895: E/AndroidRuntime(22146): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
10-11 05:34:40.895: E/AndroidRuntime(22146): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Can you help me? Some idea?
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference gsReference = storage.getReferenceFromUrl("gs://bacpoche-5ecb0.appspot.com/natio/agr-svt-2009-6-cr.jpg");
Glide.with(this )
.using(new FirebaseImageLoader())
.load(gsReference)
.into(t);
But it shows "Unfortunately YourApp has stopped".
I already have internet permission in manifest file. Below is the Error
The moniteur//E/
AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aitelred.redouane.tstv7/com.aitelred.redouane.tstv7.MainActivity}: java.lang.IllegalArgumentException: The supplied bucketname is not available to this project.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: The supplied bucketname is not available to this project.
at com.google.android.gms.common.internal.zzac.zzb(Unknown Source)
at com.google.firebase.storage.FirebaseStorage.zzz(Unknown Source)
at com.google.firebase.storage.FirebaseStorage.getReferenceFromUrl(Unknown Source)
at com.aitelred.redouane.tstv7.MainActivity.onCreate(MainActivity.java:49)
at android.app.Activity.performCreate(Activity.java:4466)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
I have a spinner that populates list of options properly at first. Then when I switch the activity and come back and tap the spinner the app crashes (see log below).
spinner1 = (Spinner) view.findViewById(R.id.fldWithSpinner1);
ArrayAdapter<?> aa = new ArrayAdapter<Object>(LocationsUI.this,
android.R.layout.simple_spinner_item,
availableLocations);
aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner1.setAdapter(aa);
Everytime when I switch to LocationsUI the spinner is created. The spinner works ok only at the first time LocationsUI is displayed, after that every time when I tap on the spinner after the LocationsUI is re-displayed, it would crash:
10-11 22:35:20.060: E/AndroidRuntime(30904): FATAL EXCEPTION: main
10-11 22:35:20.060: E/AndroidRuntime(30904): android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy#407f6d50 is not valid; is your activity running?
10-11 22:35:20.060: E/AndroidRuntime(30904): at android.view.ViewRoot.setView(ViewRoot.java:538)
10-11 22:35:20.060: E/AndroidRuntime(30904): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:203)
10-11 22:35:20.060: E/AndroidRuntime(30904): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:117)
10-11 22:35:20.060: E/AndroidRuntime(30904): at android.view.Window$LocalWindowManager.addView(Window.java:424)
10-11 22:35:20.060: E/AndroidRuntime(30904): at android.app.Dialog.show(Dialog.java:241)
10-11 22:35:20.060: E/AndroidRuntime(30904): at android.app.AlertDialog$Builder.show(AlertDialog.java:823)
10-11 22:35:20.060: E/AndroidRuntime(30904): at android.widget.Spinner.performClick(Spinner.java:261)
10-11 22:35:20.060: E/AndroidRuntime(30904): at android.view.View$PerformClick.run(View.java:9249)
10-11 22:35:20.060: E/AndroidRuntime(30904): at android.os.Handler.handleCallback(Handler.java:587)
10-11 22:35:20.060: E/AndroidRuntime(30904): at android.os.Handler.dispatchMessage(Handler.java:92)
10-11 22:35:20.060: E/AndroidRuntime(30904): at android.os.Looper.loop(Looper.java:130)
10-11 22:35:20.060: E/AndroidRuntime(30904): at android.app.ActivityThread.main(ActivityThread.java:3691)
10-11 22:35:20.060: E/AndroidRuntime(30904): at java.lang.reflect.Method.invokeNative(Native Method)
10-11 22:35:20.060: E/AndroidRuntime(30904): at java.lang.reflect.Method.invoke(Method.java:507)
10-11 22:35:20.060: E/AndroidRuntime(30904): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
10-11 22:35:20.060: E/AndroidRuntime(30904): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
10-11 22:35:20.060: E/AndroidRuntime(30904): at dalvik.system.NativeStart.main(Native Method)
10-11 22:35:20.080: E/InputDispatcher(139): channel '40abf270 com.sw.android/com.sw.MyLocAppActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x8
10-11 22:35:20.080: E/InputDispatcher(139): channel '40abf270 com.sw.android/com.sw.MyLocAppActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
Can you please show me the right direction to fix this issue?
As your Logcat says : android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy#407f6d50 is not valid; is your activity running?
This can occur when you are showing the dialog for a context that no longer exists. Here is the link which can explain you what you doing wrong exactly : http://dimitar.me/android-displaying-dialogs-from-background-threads/
and here is the code that helps you from the same link :
private Handler myHandler = new Handler() {
#Override
public void handleMessage(Message msg) {
switch (msg.what) {
case DISPLAY_DLG:
if (!isFinishing()) {
showDialog(MY_DIALOG);
}
break;
}
}
};
I receive this error
10-11 13:58:46.713: E/AndroidRuntime(29407): FATAL EXCEPTION: AsyncTask #2
10-11 13:58:46.713: E/AndroidRuntime(29407): java.lang.RuntimeException: An error occured while executing doInBackground()
10-11 13:58:46.713: E/AndroidRuntime(29407): at android.os.AsyncTask$3.done(AsyncTask.java:299)
10-11 13:58:46.713: E/AndroidRuntime(29407): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
10-11 13:58:46.713: E/AndroidRuntime(29407): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
10-11 13:58:46.713: E/AndroidRuntime(29407): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
10-11 13:58:46.713: E/AndroidRuntime(29407): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
10-11 13:58:46.713: E/AndroidRuntime(29407): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
10-11 13:58:46.713: E/AndroidRuntime(29407): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
10-11 13:58:46.713: E/AndroidRuntime(29407): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
10-11 13:58:46.713: E/AndroidRuntime(29407): at java.lang.Thread.run(Thread.java:856)
10-11 13:58:46.713: E/AndroidRuntime(29407): Caused by: java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/data/com.philly.philly/databases/PhillyORM.db
10-11 13:58:46.713: E/AndroidRuntime(29407): at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55)
10-11 13:58:46.713: E/AndroidRuntime(29407): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1310)
10-11 13:58:46.713: E/AndroidRuntime(29407): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253)
10-11 13:58:46.713: E/AndroidRuntime(29407): at com.j256.ormlite.android.AndroidCompiledStatement.getCursor(AndroidCompiledStatement.java:154)
10-11 13:58:46.713: E/AndroidRuntime(29407): at com.j256.ormlite.android.AndroidCompiledStatement.runQuery(AndroidCompiledStatement.java:57)
10-11 13:58:46.713: E/AndroidRuntime(29407): at com.j256.ormlite.stmt.SelectIterator.<init>(SelectIterator.java:55)
10-11 13:58:46.713: E/AndroidRuntime(29407): at com.j256.ormlite.stmt.StatementExecutor.buildIterator(StatementExecutor.java:206)
10-11 13:58:46.713: E/AndroidRuntime(29407): at com.j256.ormlite.stmt.StatementExecutor.query(StatementExecutor.java:155)
10-11 13:58:46.713: E/AndroidRuntime(29407): at com.j256.ormlite.dao.BaseDaoImpl.query(BaseDaoImpl.java:261)
10-11 13:58:46.713: E/AndroidRuntime(29407): at com.j256.ormlite.stmt.QueryBuilder.query(QueryBuilder.java:262)
10-11 13:58:46.713: E/AndroidRuntime(29407): at com.j256.ormlite.stmt.Where.query(Where.java:482)
10-11 13:58:46.713: E/AndroidRuntime(29407): at com.j256.ormlite.dao.BaseDaoImpl.queryForEq(BaseDaoImpl.java:241)
10-11 13:58:46.713: E/AndroidRuntime(29407): at com.philly.philly.Repository.saveOrUpdateKontext(Repository.java:180)
10-11 13:58:46.713: E/AndroidRuntime(29407): at com.philly.philly.PostListActivity$LoadPostsTask.doInBackground(PostListActivity.java:161)
10-11 13:58:46.713: E/AndroidRuntime(29407): at com.philly.philly.PostListActivity$LoadPostsTask.doInBackground(PostListActivity.java:1)
10-11 13:58:46.713: E/AndroidRuntime(29407): at android.os.AsyncTask$2.call(AsyncTask.java:287)
10-11 13:58:46.713: E/AndroidRuntime(29407): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
10-11 13:58:46.713: E/AndroidRuntime(29407): ... 5 more
I believe the key part being 10-11 13:58:46.713: E/AndroidRuntime(29407): Caused by: java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/data/com.philly.philly/databases/PhillyORM.db
This occurs when I rotate my screen while an async task is retrieving data from the remote server.
What I am assuming is happening is that the request is coming back and attempting to write to the database but the activity which started the task has been destroyed and restarted.
If you need to see my code I will add it but I thought the source of this problem might actually be pretty clear just from the error messages and my description.
I'm just looking for how to properly handle screen rotations when retrieving remote data and writing to a local database using ORMLite. Maybe I should be using a service instead of async task?
Thanks in advance.
Your activity is probably closing the DB on rotation.
My suggestion is to use an AsyncTaskLoader and it will take care of the rotation by itself. http://developer.android.com/guide/components/loaders.html
Also a tip I've learned from experience is to have a singleton DB object that will only be opened once through the whole life of your application... and when the application dies, the object is closed automatically.
You are better off using a service to take care of database. When you rotate the screen current layout with all components is destroyed and new one is build using new orientation layout (which will have other components). Also you have the option to block the rotation of screen if you don't really use it.
15 reports
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.oas.fruitkungfufree/com.openfeint.internal.ui.IntroFlow}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.openfeint.internal.Util.setOrientation(Util.java:36)
at com.openfeint.internal.ui.NestedWindow.onCreate(NestedWindow.java:32)
at com.openfeint.internal.ui.WebNav.onCreate(WebNav.java:93)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
Does any one have a solution for this??
This is a problem with your code, you can't use an object that is null. This is a hint.