来自Marakana的MyTwitter应用程序。 http://marakana.com/forums/android/examples/312.html
Marakana简单的OAuth演示。 https://github.com/marakana/OAuthDemo
Twitter4j示例itog_lab。 https://github.com/itog/Twitter4j-android-Sample
AndroidTwitterSample。 http://www.android10.org/index.php/articleslibraries/291-twitter-integration-in-your-android-application#josc329
我总是遇到未经授权的错误,无法请求访问令牌。有没有人有这种经历?
答案 0 :(得分:4)
如果您满足于使用Intent调用Twitter(意味着您需要已经安装的Twitter应用程序才能工作),您可以使用以下内容访问Twitter:
try{
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "It's a Tweet!" + "#MyApp");
intent.setType("text/plain");
final PackageManager pm = getPackageManager();
final List<?> activityList = pm.queryIntentActivities(intent, 0);
int len = activityList.size();
for (int i = 0; i < len; i++) {
final ResolveInfo app = (ResolveInfo) activityList.get(i);
if ("com.twitter.android.PostActivity".equals(app.activityInfo.name)) {
final ActivityInfo activity=app.activityInfo;
final ComponentName name=new ComponentName(activity.applicationInfo.packageName, activity.name);
intent=new Intent(Intent.ACTION_SEND);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
intent.setComponent(name);
intent.putExtra(Intent.EXTRA_TEXT, "It's a Tweet!" + "#MyApp");
startActivity(intent);
break;
}
}
} catch(final ActivityNotFoundException e) {
Log.i("Twitter intent", "no twitter native", e );
}
答案 1 :(得分:0)
我的例子有效http://schwiz.net/blog/2011/using-scribe-with-android/如果你遇到麻烦就ping我。