Android Question another date picker. attempt to invoke method on null object

le_toubib

Active Member
Licensed User
hi falks
i'm trying to implement another date picker in a project.
it works perfectly ok ,
however , on the FIRST run on any device , i get this error :


Installing file.
PackageAdded: package:dardiries.omnia.wisc
** Activity (main) Create, isFirst = true **
Object context is paused. Ignoring CallSubDelayed: AddToActivity
** Activity (main) Resume **
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Canvas.drawColor(int, android.graphics.PorterDuff$Mode)' on a null object reference
at anywheresoftware.b4a.objects.drawable.CanvasWrapper.DrawColor(CanvasWrapper.java:131)
at dardiries.omnia.wisc.anotherdatepicker._drawdays(anotherdatepicker.java:510)
at dardiries.omnia.wisc.anotherdatepicker._show(anotherdatepicker.java:797)
at dardiries.omnia.wisc.main._dob_click(main.java:1570)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:77)
at android.view.View.performClick(View.java:4785)
at android.view.View$PerformClick.run(View.java:19858)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5696)
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:1028)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)

if i close it and rerun , it shows perfectly thereafter.. the error is replicated on Same device if i uninstall/reinstall


what am i doing wrong ?
 

Mahares

Well Known Member
Licensed User
here it is
When you post code for users to help you with, you should leave it there even after you were provided a solution. It may help someone else in the future. You should not remove it, just because your problem is solved. if you expect help from others, you should also give help.
 

le_toubib

Active Member
Licensed User
When you post code for users to help you with, you should leave it there even after you were provided a solution. It may help someone else in the future. You should not remove it, just because your problem is solved. if you expect help from others, you should also give help.
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("1")
    SetTiledBackground(pnl_inputdata,LoadBitmap(File.DirAssets,"tile82x82.png"))
    SetTiledBackground(pnl_preview,LoadBitmap(File.DirAssets,"tile82x82.png"))
    SetTiledBackground(pnl_print,LoadBitmap(File.DirAssets,"tile82x82.png"))
    'SetTiledBackground(pnl_settings,LoadBitmap(File.DirAssets,"tile82x82.png"))

    If FirstTime Then
        SMTP.Initialize("smtp.gmail.com", 587, "", "", "SMTP")
        SMTP.StartTLSMode = True
    End If
    WebView1.Initialize("webview1")

    pnl_preview.AddView(WebView1,0,0,550dip,90%y)

    lst_prev_names.Initialize
    lst_places.Initialize
    lst_sources.Initialize

    readcomments
  

If File.Exists(File.DirRootExternal & dirname, "settings.ini") Then  
    readsettings
    readplaces
Else
    File.MakeDir(File.DirRootExternal,dirname)
    readsettings
    readplaces
End If

savesettings
    DateTime.DateFormat="dd-MM-yyyy"

    acet1.SetItems(lst_prev_names)
    acet2.SetItems(lst_places)
    createlabelsandspinners
  
    lbl_date.Text=lbl_date.Text & DateTime.Date(DateTime.Now)
    spn_test_type.Add("WISC")
    spn_test_type.Add("WAIS")
    spn_test_type.SelectedIndex=0

    'spn_test_type.Background=b_share.Background




End Sub

sure mate
 
Last edited by a moderator:
Top