android - Security Exception : Permission Denial on posting to Twitter -


i trying post on twitter using below code

 intent intent = new intent(android.content.intent.action_send);     intent.settype("text/plain");     final packagemanager pm = context.getpackagemanager();     final list<resolveinfo> activitylist = pm.queryintentactivities(intent, 0);     (final resolveinfo app : activitylist) {         if (app.activityinfo.packagename.endswith(package_twitter)) {             final activityinfo activity = app.activityinfo;             final componentname name = new componentname(activity.applicationinfo.packagename, activity.name);             intent.addcategory(intent.category_launcher);             intent.setflags(intent.flag_activity_new_task | intent.flag_activity_reset_task_if_needed);             intent.putextra(intent.extra_text, strbody);             intent.setcomponent(name);             context.startactivity(intent);             break;         }     } 

and code throws security exception. please help.

you need set android:exported="true" in androidmanifest.xml file declare activity.

<activity    android:exported="true">    <intent-filter>       <action android:name="android.intent.action.main" >       </action>    </intent-filter> </activity> 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -