Reputation: 53
I have problem with my function for posting data on Facebook:
public void postData() {
try {
Intent i = new Intent(Intent.ACTION_SEND);
i.setClassName("com.facebook.katana",
"com.facebook.katana.ShareLinkActivity");
i.setType("text/*");
i.putExtra(android.content.Intent.EXTRA_TEXT, "http://sample_url.com");
startActivity(i);
} catch (Exception e) {
Intent i= new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("http://sample_url.com));
startActivity(i);
}
}
Every time I get information that activity com.facebook.katana.ShareLinkActivity can't be run and I should add code to the Android manifest. Facebook application is installed on the phone.
In AndroidManifest.xml:
<activity android:name="com.facebook.katana.ShareLinkActivity" >
</activity>
Exception in LogCat:
01-30 14:46:00.903: E/AndroidRuntime(11626): FATAL EXCEPTION: main
01-30 14:46:00.903: E/AndroidRuntime(11626): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.facebook.katana/com.facebook.katana.ShareLinkActivity}; have you declared this activity in your AndroidManifest.xml?
01-30 14:46:00.903: E/AndroidRuntime(11626): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1634)
01-30 14:46:00.903: E/AndroidRuntime(11626): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1510)
01-30 14:46:00.903: E/AndroidRuntime(11626): at android.app.Activity.startActivityFromChild(Activity.java:3531)
01-30 14:46:00.903: E/AndroidRuntime(11626): at android.app.Activity.startActivityForResult(Activity.java:3283)
01-30 14:46:00.903: E/AndroidRuntime(11626): at android.app.Activity.startActivity(Activity.java:3370)
Upvotes: 3
Views: 4434
Reputation: 2835
Just so we are all on the same page with this. Facebook has intentionally broken this and refuses to fix it and shame on them for doing so.
https://developers.facebook.com/bugs/332619626816423
Upvotes: 0
Reputation: 610
for all of those who are using appcelerator here how got it to work...
var intFB = Ti.Android.createIntent({
action : Ti.Android.ACTION_SEND,
packageName : "com.facebook.katana",
type : "text/plain"
});
intFB.putExtra(Ti.Android.EXTRA_TEXT, "http://www.google.com");
//facebook only supports LINKS(!!!)
Ti.Android.currentActivity.startActivity(intFB);
Upvotes: 1
Reputation: 1075
Finally I got this code to work:
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
sharingIntent.putExtra(Intent.EXTRA_TEXT, "Text...");
sharingIntent.setPackage("com.facebook.katana");
startActivity(sharingIntent);
Main points are setPackage
and setType
- now Android chooses right activity from Facebook package.
Upvotes: 10
Reputation: 9020
Yes...you should declare com.facebook.katana.ShareLinkActivity
in AndroidManifest.xml
file. This should do.
Edit:
O o ... problem lies in setClassName
method. Replace your following line
i.setClassName("com.facebook.katana","com.facebook.katana.ShareLinkActivity");
with this one:
i.setClassName("com.facebook.katana","ShareLinkActivity");
As second parameter in the method is className
and you were also passing package name with the class name which the debugger was unable to find. As class name is ShareLinkActivity
not com.facebook.katana.ShareLinkActivity
.
This will finally solve your problem.
Upvotes: 0