Giter VIP home page Giter VIP logo

Comments (5)

alexbbb avatar alexbbb commented on May 22, 2024

As the exception says:

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.Application android.app.Activity.getApplication()' on a null object reference
        at com.nuro.messaging.ChatFragment.sendMessage(ChatFragment.java:479)
        at com.nuro.messaging.ChatFragment.access$500(ChatFragment.java:63)
        at com.nuro.messaging.ChatFragment$11.onCompleted(ChatFragment.java:648)
        at com.alexbbb.uploadservice.AbstractUploadServiceReceiver.onReceive(AbstractUploadServiceReceiver.java:38)

You're invoking a method on a null object in your custom implementation of AbstractUploadServiceReceiver's onCompleted method. Debug your code.

from android-upload-service.

droididan avatar droididan commented on May 22, 2024

Hi Alex,

Thank, i'm noob programmer :) working on my skills. but thank you for best
support.

Idan

On Mon, Mar 9, 2015 at 3:36 PM, Alex Gotev [email protected] wrote:

As the exception says:

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.Application android.app.Activity.getApplication()' on a null object reference
at com.nuro.messaging.ChatFragment.sendMessage(ChatFragment.java:479)

You're invoking a method on a null object in your custom implementation of
AbstractUploadServiceReceiver's onReceive method. Debug your code.

Reply to this email directly or view it on GitHub
#24 (comment)
.

Idan Ayalon

from android-upload-service.

alexbbb avatar alexbbb commented on May 22, 2024

@idanbar134 keep working like you do :) I suggest you to learn how to read Java Stack Trace, as it's your "best friend" to find out what's going wrong in some cases. Sorry to bother you with this ticket you opened: #22 again, but I need to know if you still have the described problem or how you managed to solve it :)

from android-upload-service.

droididan avatar droididan commented on May 22, 2024

Thanks. I learn the hard way :) and I solved it.
On Mar 9, 2015 4:54 PM, "Alex Gotev" [email protected] wrote:

@idanbar134 https://github.com/idanbar134 keep working like you do :) I
suggest you to learn how to read Java Stack Trace, as it's your "best
friend" to find out what's going wrong in some cases. Sorry to bother you
with this ticket you opened: #22
#22 again, but
I need to know if you still have the described problem or how you managed
to solve it :)

Reply to this email directly or view it on GitHub
#24 (comment)
.

from android-upload-service.

droididan avatar droididan commented on May 22, 2024

Hi Alex,

I'm trying to upload a photo that i pick from the gallery using this code:

public String getPath(Uri uri) {
// just some safety built in
if( uri == null ) {
return null;
}
// try to retrieve the image from the media store first
// this will only work for images selected from gallery
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = getActivity().getContentResolver().query(uri,
projection, null, null, null);
if( cursor != null ){
int column_index =
cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
// this is our fallback here
return uri.getPath();
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent

data) {
super.onActivityResult(requestCode, resultCode, data);
String realPath = "";

    if (resultCode == Activity.RESULT_OK  ) {
        if( requestCode == REQUEST_CAPTURE_PICTURE ){
            file = new

File(Environment.getExternalStorageDirectory().toString());
for (File temp : file.listFiles()) {
if (temp.getName().equals("temp.jpg")) {
file = temp;

                   realPath = file.toString();
                    break;
                }
            }
        }

        if (requestCode ==  REQUEST_PICK_PICTURE) {
            if (data != null ) {
                selectedImageURI = data.getData();
                Log.i(TAG, selectedImageURI.toString());

                //realPath =

"/storage/emulated/legacy/20150308_184443.jpg";

                realPath = getPath(selectedImageURI);

            }
        }

        // upload the files with android-upload-service
        UploadFileToServer(realPath, getActivity());
    }
}

and this is my chooseImage method:

private void chooseImage() {
    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent, "Select

Picture"), REQUEST_PICK_PICTURE);
}

the 'getPath' returns empty string and the app crashes...
i tried to direct 'realPath' (String) to real photo on SD and it worked.

i would be happy to know what is my noob mistake this time :)

best,

Idan

On Mon, Mar 9, 2015 at 4:57 PM, idanbar134 [email protected] wrote:

Thanks. I learn the hard way :) and I solved it.
On Mar 9, 2015 4:54 PM, "Alex Gotev" [email protected] wrote:

@idanbar134 https://github.com/idanbar134 keep working like you do :)
I suggest you to learn how to read Java Stack Trace, as it's your "best
friend" to find out what's going wrong in some cases. Sorry to bother you
with this ticket you opened: #22
#22 again, but
I need to know if you still have the described problem or how you managed
to solve it :)

Reply to this email directly or view it on GitHub
#24 (comment)
.

Idan Ayalon

from android-upload-service.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.