android - Share intent with extra text and image -
i trying share info application in andriod.
i tried this, it's working slow. there better way this?
try { uri imageuri = null; try { imageuri = uri.parse(mediastore.images.media.insertimage(context.getcontentresolver(), bitmap, null, null)); } catch (exception e) {e.printstacktrace();} shareintent = new intent(); shareintent.setaction(intent.action_send); shareintent.putextra(intent.extra_text, contenttext); shareintent.putextra(intent.extra_stream, imageuri); shareintent.settype("*/*"); } catch (android.content.activitynotfoundexception ex) { ex.printstacktrace(); } new popupsharedialog().new launchables(context, dialogshare, socialgv).execute(); class launchables extends asynctask<string, string, jsonobject>{ progressdialog progressdialog; context context; list<resolveinfo> launchables; dialog dialogshare; expandableheightgridview socialgv; public launchables(context context, dialog dialogshare, expandableheightgridview socialgv){ this.dialogshare = dialogshare; this.socialgv = socialgv; this.context = context; } @override protected void onpreexecute() { progressdialog = progressdialog.show(context, "", "" + context.getstring(r.string.popup_loaded)); } @override protected jsonobject doinbackground(string... params) { // todo auto-generated method stub launchables = context.getpackagemanager().queryintentactivities(shareintent, 0); return null; } @override protected void onpostexecute(jsonobject json) { progressdialog.dismiss(); log.d("", "packagemanager"); collections.sort(launchables, new resolveinfo.displaynamecomparator(context.getpackagemanager())); sharesocadapter = new sharesocialsadapter(context.getpackagemanager(), launchables, context); socialgv.setadapter(sharesocadapter); socialgv.setonitemclicklistener(new android.widget.adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> arg0, view arg1, int position, long arg3) { resolveinfo launchable = sharesocadapter.getitem(position); activityinfo activity = launchable.activityinfo; componentname name = new componentname(activity.applicationinfo.packagename, activity.name); shareintent.addcategory(intent.category_launcher); shareintent.setflags(intent.flag_activity_new_task |intent.flag_activity_reset_task_if_needed); shareintent.setcomponent(name); context.startactivity(shareintent); } }); dialogshare.show(); } }
Comments
Post a Comment