Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8431443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:51:25+00:00 2026-06-10T05:51:25+00:00

Iam trying to use remoteviews with notification in my application.But when i run my

  • 0

Iam trying to use remoteviews with notification in my application.But when i run my aplication i got E/AndroidRuntime(11337): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.jeema.HWDTest/net.jeema.HWDTest.HWDTestActivity}: java.lang.NullPointerException.Dont know why it is happening.Iam new to android.Please help me.Cant get a hint why iam getting runtime exception here.

My code:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT;
        final RemoteViews contentView = new RemoteViews(getPackageName(),
                R.layout.upload_progress_bar);
        contentView.setProgressBar(R.id.progress_bar, MAX_PROGRESS,
                mProgressStatus, false);
        notification=new Notification();
        notification.contentView = contentView;

        // Start file upload in a background thread
        new Thread(new Runnable() {
            public void run() {
                while (mProgressStatus < MAX_PROGRESS) {
                    mProgressStatus = doWork();

                    // Update the progress bar
                    mHandler.post(new Runnable() {
                        public void run() {
                            contentView.setProgressBar(R.id.progress_bar,
                                    MAX_PROGRESS, mProgressStatus, false);
                        }
                    });
                }
            }

            private int doWork() {
                HttpURLConnection conn = null;
                DataOutputStream dos = null;
                DataInputStream inStream = null;
                String lineEnd = "\r\n";
                String twoHyphens = "--";
                String boundary = "*****";
                int bytesRead;
                byte[] buffer;
                String urlString = "http://xxxxx/xxxx/xxx.php";
                try {
                    UUID uniqueKey = UUID.randomUUID();
                    fname = uniqueKey.toString();
                    Log.e("UNIQUE NAME", fname);
                    FileInputStream fileInputStream = new FileInputStream(
                            new File(selectedPath));
                    URL url = new URL(urlString);
                    conn = (HttpURLConnection) url.openConnection();
                    int length = fileInputStream.available();
                    System.out.println("Video Length--->>>>" + length);
                    conn.setDoInput(true);
                    conn.setDoOutput(true);
                    conn.setUseCaches(false);
                    conn.setRequestMethod("POST");
                    conn.setRequestProperty("Connection", "Keep-Alive");
                    conn.setRequestProperty("Content-Type",
                            "multipart/form-data;boundary=" + boundary);
                    dos = new DataOutputStream(conn.getOutputStream());
                    dos.writeBytes(twoHyphens + boundary + lineEnd);
                    dos.writeBytes("Content-Disposition: form-data; name=\"uploadedfile\";filename=\""
                            + fname + "" + lineEnd);
                    dos.writeBytes(lineEnd);
                    buffer = new byte[8192];
                    bytesRead = 0;
                    while ((bytesRead = fileInputStream.read(buffer)) > 0) {
                        dos.write(buffer, 0, bytesRead);
                    }
                    dos.writeBytes(lineEnd);
                    dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
                    Log.e("Debug", "File is written");
                    fileInputStream.close();
                    dos.flush();
                    dos.close();

                } catch (MalformedURLException ex) {
                    Log.e("Debug", "error: " + ex.getMessage(), ex);
                } catch (IOException ioe) {
                    Log.e("Debug", "error: " + ioe.getMessage(), ioe);
                }
                // ------------------ read the SERVER RESPONSE
                try {
                    inStream = new DataInputStream(conn.getInputStream());
                    String str;
                    while ((str = inStream.readLine()) != null) {
                        Log.e("Debug", "Server Response " + str);
                    }
                    inStream.close();

                } catch (IOException ioex) {
                    Log.e("Debug", "error: " + ioex.getMessage(), ioex);
                }
                return 0;
            }
        }).start();
    }

My logcat:

08-26 14:15:49.542: E/AndroidRuntime(12359): FATAL EXCEPTION: main
08-26 14:15:49.542: E/AndroidRuntime(12359): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.jeema.HWDTest/net.jeema.HWDTest.HWDTestActivity}: java.lang.NullPointerException
08-26 14:15:49.542: E/AndroidRuntime(12359):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
08-26 14:15:49.542: E/AndroidRuntime(12359):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-26 14:15:49.542: E/AndroidRuntime(12359):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-26 14:15:49.542: E/AndroidRuntime(12359):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-26 14:15:49.542: E/AndroidRuntime(12359):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-26 14:15:49.542: E/AndroidRuntime(12359):    at android.os.Looper.loop(Looper.java:123)
08-26 14:15:49.542: E/AndroidRuntime(12359):    at android.app.ActivityThread.main(ActivityThread.java:3683)
08-26 14:15:49.542: E/AndroidRuntime(12359):    at java.lang.reflect.Method.invokeNative(Native Method)
08-26 14:15:49.542: E/AndroidRuntime(12359):    at java.lang.reflect.Method.invoke(Method.java:507)
08-26 14:15:49.542: E/AndroidRuntime(12359):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-26 14:15:49.542: E/AndroidRuntime(12359):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-26 14:15:49.542: E/AndroidRuntime(12359):    at dalvik.system.NativeStart.main(Native Method)
08-26 14:15:49.542: E/AndroidRuntime(12359): Caused by: java.lang.NullPointerException
08-26 14:15:49.542: E/AndroidRuntime(12359):    at net.jeema.HWDTest.HWDTestActivity.onCreate(HWDTestActivity.java:36)
08-26 14:15:49.542: E/AndroidRuntime(12359):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-26 14:15:49.542: E/AndroidRuntime(12359):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-26 14:15:49.542: E/AndroidRuntime(12359):    ... 11 more

My manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="net.jeema.HWDTest"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="10" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".HWDTestActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>         
    </application>

</manifest>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:51:27+00:00Added an answer on June 10, 2026 at 5:51 am

    you are using the notification before you create it… try it this way:

    notification=new Notification();
    notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

iam trying to bold / italic text but i use this code to bold
iam trying to use the math.trunc in Blender 2.49b Python but iam getting this
Iam tyring to use this slider: http://www.menucool.com/javascript-image-slider BUT when Iam trying to use a
Iam trying to use System.Web.UI.WebControls.Calender. But when I select any date , It post
Iam trying to use a UserControl named CheckBoxControl as value for the ExpandControlID/CollapseControlID attributes
I am trying use gem tire to search in my application. I have tables
I am trying use a Java Uploader in a ROR app (for its ease
I am trying to use new Google Cloud Messaging system but I have some
Iam trying to build an Facebook Application based on PHP. The Application is running
I am trying use filehelpers class builder but I am kinda confused on what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.