2

I have the same code as this question to post on Twitter from Android App. But I would like to add some text non editable by the user, or attach a image directlý.

  • 1) Is possible to do without add a jar, with intent parameters?

  • 2) If not, Is possible to do only with JSON request directly?

I can send a Tweet with this code:

// Create Intent
Intent tweetIntent = new Intent(Intent.ACTION_SEND);
tweetIntent.putExtra(Intent.EXTRA_TEXT, "This is a Test.");
tweetIntent.setType("text/plain");

// Create query to Tweet
PackageManager packManager = getPackageManager();
List<ResolveInfo> resolvedInfoList = packManager.queryIntentActivities(tweetIntent,  PackageManager.MATCH_DEFAULT_ONLY);

// Look for native App in device
boolean resolved = false;
for(ResolveInfo resolveInfo: resolvedInfoList){
    if(resolveInfo.activityInfo.packageName.startsWith("com.twitter.android")){
        tweetIntent.setClassName(
            resolveInfo.activityInfo.packageName, 
            resolveInfo.activityInfo.name );
        resolved = true;
        break;
    }
}
if(resolved)
{
    startActivity(tweetIntent);
}
else
{
    Toast.makeText(this, "Twitter app isn't found", Toast.LENGTH_LONG).show();
}

But the Text is editable by the user. I would like to post directly (I don´t know if this is possible because i´m not usint the Twitter API) or make the text non-editable.

Community
  • 1
  • 1
vgonisanz
  • 11,831
  • 13
  • 78
  • 130

0 Answers0