Hello guys
I am trying to build an application with 2 activities one is the main activity and the second activity which contain ImageView, and a 3 button’s. I want when I press the button to set as wallpaper the current image displayed in the ImageView . The problem is when I set the code for the Set Wallpaper button the first main activity is accessed without problems, but when I try to access the second activity the app crashes as you can see in the log. If I don’t configure the Set Wallpaper button, the code for the next and previous buttons runs smoothly. I tried several options and methods to configure the onClick for the Set Wallpaper button. Please help me with this problem. Here is my code:
Code:
public class Castles extends Activity {
protected static InputStream is;
public int currentImage = 0;
int[] imageIds = {
R.drawable.cas1,R.drawable.cas2,R.drawable.cas3,R.drawable.cas4,R.drawable.cas5,R.drawable.cas6,
R.drawable.cas7, R.drawable.cas8, R.drawable.cas9,R.drawable.cas10,R.drawable.cas11,R.drawable.cas12,
R.drawable.cas13,R.drawable.cas14,R.drawable.cas15,R.drawable.cas16, R.drawable.cas17,R.drawable.cas18,
R.drawable.cas19,R.drawable.cas20,R.drawable.cas21};
private Button BNatNext;
private Button BNatPri;
private Button BSetWallNat;
private ImageView IVNat;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.castles);
IVNat = (ImageView)findViewById(R.id.IVNat);
BNatNext=(Button)findViewById(R.id.BNatNext);
BNatPri=(Button)findViewById(R.id.BNatPri);
BNatNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
currentImage++;
currentImage=currentImage%imageIds.length;
IVNat.setImageResource(imageIds[currentImage]);
}
});
BNatPri.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
currentImage--;
currentImage=(currentImage+imageIds.length)%imageIds.length;
IVNat.setImageResource(imageIds[currentImage]);
}
});
BSetWallNat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
try {
} catch(IOException e){
Log.e("Tag", "couldn't set wallpaper", e);
}
}
And this is the LogCat:
Code:
12-04 21:44:15.205: D/dalvikvm(1223): GC_EXTERNAL_ALLOC freed 44K, 51% free 2670K/5379K, external 1527K/1559K, paused 418ms
12-04 21:44:18.282: D/dalvikvm(1223): GC_EXTERNAL_ALLOC freed 1K, 51% free 2669K/5379K, external 4560K/5695K, paused 486ms
12-04 21:44:24.043: D/gralloc_goldfish(1223): Emulator without GPU emulation detected.
12-04 21:44:27.853: D/dalvikvm(1223): GC_EXTERNAL_ALLOC freed 11K, 50% free 2698K/5379K, external 7974K/7974K, paused 201ms
12-04 21:44:32.223: D/dalvikvm(1223): GC_EXTERNAL_ALLOC freed 2K, 50% free 2702K/5379K, external 11198K/11388K, paused 321ms
12-04 21:44:34.903: D/AndroidRuntime(1223): Shutting down VM
12-04 21:44:34.903: W/dalvikvm(1223): threadid=1: thread exiting with uncaught exception (group=0xb609d4f0)
12-04 21:44:34.963: E/AndroidRuntime(1223): FATAL EXCEPTION: main
12-04 21:44:34.963: E/AndroidRuntime(1223): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Roapps.wallpaperhd/com.Roapps.wallpaperhd.Castles}: java.lang.NullPointerException
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.os.Handler.dispatchMessage(Handler.java:99)
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.os.Looper.loop(Looper.java:130)
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-04 21:44:34.963: E/AndroidRuntime(1223): at java.lang.reflect.Method.invokeNative(Native Method)
12-04 21:44:34.963: E/AndroidRuntime(1223): at java.lang.reflect.Method.invoke(Method.java:507)
12-04 21:44:34.963: E/AndroidRuntime(1223): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-04 21:44:34.963: E/AndroidRuntime(1223): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-04 21:44:34.963: E/AndroidRuntime(1223): at dalvik.system.NativeStart.main(Native Method)
12-04 21:44:34.963: E/AndroidRuntime(1223): Caused by: java.lang.NullPointerException
12-04 21:44:34.963: E/AndroidRuntime(1223): at com.Roapps.wallpaperhd.Castles.onCreate(Castles.java:63)
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
12-04 21:44:34.963: E/AndroidRuntime(1223): ... 11 more
12-04 21:44:38.963: I/Process(1223): Sending signal. PID: 1223 SIG: 9
Process: com.android.systemui
Flags: 0x40d83e0d
Package: com.android.systemui v21 (5.0.2-G850FXXU2COK1)
Build: samsung/sltexx/slte:5.0.2/LRX22G/G850FXXU2COK1:user/release-keys
java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View com.android.systemui.qs.QSEditPanel.findViewById(int)' on a null object reference
at com.android.systemui.statusbar.phone.PhoneStatusBar$3.onOpenThemeChanged(PhoneStatusBar.java:663)
at com.android.keyguard.KeyguardUpdateMonitor.handleOpenThemeChangeUpdate(KeyguardUpdateMonitor.java:1521)
at com.android.keyguard.KeyguardUpdateMonitor.access$1600(KeyguardUpdateMonitor.java:102)
at com.android.keyguard.KeyguardUpdateMonitor$1.handleMessage(KeyguardUpdateMonitor.java:306)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6117)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
i edit qseditpanel, phonestatusbar etc. but same error.
Here is the main error from my logcat:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at com.example.milespc.funfacts.ActivityFunFacts.onCreate(ActivityFunFacts.java:50)
and here is the line where it says it is getting the null:
showFactButton.setOnClickListener(listener);
Can someone please help me figure this out?
Hey there,
I tried the PdfRenderer Sample Project on serveral AVDs (API lvl 23 and 24) and on my Galaxy A5 2015 with CM13 (API 23). the app starts and shows an empty activity - after about 10 seconds it crashes.
The Error:
Code:
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.pdfrendererbasic, PID: 27604
Theme: themes:{default=overlay:system, iconPack:system, fontPkg:system, com.android.systemui=overlay:system, com.android.systemui.navbar=overlay:system}
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.pdfrendererbasic/com.example.android.pdfrendererbasic.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.pdf.PdfRenderer.getPageCount()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2450)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5461)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.pdf.PdfRenderer.getPageCount()' on a null object reference
at com.example.android.pdfrendererbasic.PdfRendererBasicFragment.showPage(PdfRendererBasicFragment.java:163)
at com.example.android.pdfrendererbasic.PdfRendererBasicFragment.onViewCreated(PdfRendererBasicFragment.java:101)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:988)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
at android.app.BackStackRecord.run(BackStackRecord.java:793)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535)
at android.app.FragmentController.execPendingActions(FragmentController.java:325)
at android.app.Activity.performStart(Activity.java:6267)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510)*
at android.app.ActivityThread.-wrap11(ActivityThread.java)*
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363)*
at android.os.Handler.dispatchMessage(Handler.java:102)*
at android.os.Looper.loop(Looper.java:148)*
at android.app.ActivityThread.main(ActivityThread.java:5461)*
at java.lang.reflect.Method.invoke(Native Method)*
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)*
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)*
Application terminated.
What did I do wrong?
LG Christopher
Hi all. I'm on Samsung note 4 AICP android pie.
Apps created with adobe air crash.
Here is the log
https://haste.aicp-rom.com/yafetacobu
Code:
time: 1578832729710
msg: java.lang.UnsatisfiedLinkError: No implementation found for void com.adobe.air.AIRWindowSurfaceView.nativeSurfaceCreated() (tried Java_com_adobe_air_AIRWindowSurfaceView_nativeSurfaceCreated and Java_com_adobe_air_AIRWindowSurfaceView_nativeSurfaceCreated__)
stacktrace: java.lang.UnsatisfiedLinkError: No implementation found for void com.adobe.air.AIRWindowSurfaceView.nativeSurfaceCreated() (tried Java_com_adobe_air_AIRWindowSurfaceView_nativeSurfaceCreated and Java_com_adobe_air_AIRWindowSurfaceView_nativeSurfaceCreated__)
at com.adobe.air.AIRWindowSurfaceView.nativeSurfaceCreated(Native Method)
at com.adobe.air.AIRWindowSurfaceView.surfaceCreated(AIRWindowSurfaceView.java:721)
at android.view.SurfaceView.updateSurface(SurfaceView.java:670)
at android.view.SurfaceView$2.onPreDraw(SurfaceView.java:143)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:977)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2492)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1484)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7385)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1012)
at android.view.Choreographer.doCallbacks(Choreographer.java:823)
at android.view.Choreographer.doFrame(Choreographer.java:758)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:998)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6672)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:860)
thx