java - Action Intent not receiving extra stream -
i have app working great when using android.intent.action.send. user pdf via share adobe. when change manifest file android.intent.action.view receive "attempt invoke virtual method 'java.lang.object android.os.bundle.get(java.lang.string)' on null object reference"
the reason need view because user needs open email , click preview on file attachment chooses app. there want able use itext edit pdf. if don't add android.intent.action.view program not on list.
public void existingpdf(view view) { intent intent = getintent(); string action = intent.getaction(); string type = intent.gettype(); //intent.setaction(android.content.intent.action_view); try { //intent intent = intent(); // uri pdfuri = (uri) getintent().getextras().get(intent.extra_stream); pdfreader pdfreader = new pdfreader(pdfuri.getpath()); //pdfreader pdfreader = new pdfreader(android.os.environment.getexternalstoragedirectory().getpath()+ file.separatorchar + "testfile.pdf"); pdfstamper pdfstamper = new pdfstamper(pdfreader, new fileoutputstream(android.os.environment.getexternalstoragedirectory().getpath()+ file.separatorchar + "testfilemodified.pdf")); image image = image.getinstance(android.os.environment.getexternalstoragedirectory().getpath()+ file.separatorchar + "temp.jpg"); for(int i=1; i<= pdfreader.getnumberofpages(); i++){ //put content under pdfcontentbyte content = pdfstamper.getundercontent(i); image.setabsoluteposition(100f, 150f); image.scaletofit(100, 125); content.addimage(image); //put content on //content = pdfstamper.getovercontent(i); //image.setabsoluteposition(100f, 150f); //image.scaletofit(100,125); //content.addimage(image); msubjectedittext = (textview) findviewbyid(r.id.edit_text_subject); msubjectedittext = (textview) findviewbyid(r.id.edit_text_subject); //text on existing page basefont bf = basefont.createfont(basefont.helvetica, basefont.winansi, basefont.embedded); content.begintext(); content.setfontandsize(bf, 18); //content.showtextaligned(pdfcontentbyte.align_left, "page no: " + i, 130, 15, 0); content.showtextaligned(pdfcontentbyte.align_left, msubjectedittext.gettext().tostring(),150, 120, 0); content.endtext(); toast.maketext(getapplicationcontext(), "completed", toast.length_long).show(); } pdfstamper.close(); } catch (ioexception e) { e.printstacktrace(); //toast.maketext(getapplicationcontext(), (charsequence) e, toast.length_long).show(); log.e("error", string.valueof(e)); } catch (documentexception e) { e.printstacktrace(); //toast.maketext(getapplicationcontext(), (charsequence) e, toast.length_long).show(); log.e("error document", string.valueof(e)); } }
log cat:
08-03 18:08:21.627 22067-22067/com.example.tony.electricportal247 e/androidruntime﹕ fatal exception: main process: com.example.tony.electricportal247, pid: 22067 java.lang.illegalstateexception: not execute method of activity @ android.view.view$1.onclick(view.java:4247) @ android.view.view.performclick(view.java:5191) @ android.view.view$performclick.run(view.java:20916) @ android.os.handler.handlecallback(handler.java:739) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:145) @ android.app.activitythread.main(activitythread.java:5972) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1399) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1194) caused by: java.lang.reflect.invocationtargetexception @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ android.view.view$1.onclick(view.java:4242) at android.view.view.performclick(view.java:5191) at android.view.view$performclick.run(view.java:20916) at android.os.handler.handlecallback(handler.java:739) at android.os.handler.dispatchmessage(handler.java:95) at android.os.looper.loop(looper.java:145) at android.app.activitythread.main(activitythread.java:5972) 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) caused by: java.lang.nullpointerexception: attempt invoke virtual method 'java.lang.object android.os.bundle.get(java.lang.string)' on null object reference @ com.example.tony.electricportal247.createpdf.existingpdf(createpdf.java:172) at java.lang.reflect.method.invoke(native method) at java.lang.reflect.method.invoke(method.java:372) at android.view.view$1.onclick(view.java:4242) at android.view.view.performclick(view.java:5191) at android.view.view$performclick.run(view.java:20916) at android.os.handler.handlecallback(handler.java:739) at android.os.handler.dispatchmessage(handler.java:95) at android.os.looper.loop(looper.java:145) at android.app.activitythread.main(activitythread.java:5972) 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)
Comments
Post a Comment