加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

java.lang.NullPointerException:Attempttoinvokevirtualmethodandroid.app.ActivityThread$App

(2023-10-16 00:46:44)
分类: androidios

转:/questions/53748248/java-lang-nullpointerexception-attempt-to-invoke-virtual-method-android-app-ac


I know this may be a duplicate but my situation is different which requires some explanation on this specific issue.

I'm getting the error :

java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference

In the onClick the method addEvent is called from the class MyCalendar


button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            MyCalendar myCalendar = new MyCalendar();
            myCalendar.addEvent();
          //  myCalendar.AddEvent(2,context);
       }
    });

It calls the below method


public void addEvent(){
    Calendar beginTime = Calendar.getInstance();
    beginTime.set(2018, 11, 14, 7, 30);
    Calendar endTime = Calendar.getInstance();
    endTime.set(2018, 11, 14, 8, 30);
        Intent intent = new Intent(Intent.ACTION_INSERT)
            .setData(Events.CONTENT_URI)
            .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getTimeInMillis())
            .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis())
            .putExtra(Events.TITLE, "TEST ANDROID")
            .putExtra(Events.DESCRIPTION, "EVENT HAS BEEN ADDED FROM ANDROID STUDIO")
            .putExtra(Events.EVENT_LOCATION, "GIBRALTAR")
            .putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY)
            .putExtra(Events.CALENDAR_ID, 2)
            .putExtra(Intent.EXTRA_EMAIL, "example@test.com");
    startActivity(intent);
}

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有