Caros, estou testando uma opção para compartilhar um certo conteudo em redes sociais. No momento estou conseguindo compartilhar pelo facebook por intermédio do próprio sdk do facebook. Entretanto, também estou tentando usar o Intent.Action_Send do próprio android e nisso estou tendo problemas. Segue o código para análise:
class Compartilhar extends Activity implements OnClickListener {
private Causa causa;
Context cxt;
// Your Facebook APP ID
private static String APP_ID = "xxxxxxxxxx"; // Replace with your App ID
// Instance of Facebook Class
private Facebook fb = new Facebook(APP_ID);
private AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(fb);
public Compartilhar(Causa causa){
this.causa = causa;
}
public void onClick(View v) {
final Button btCompartilhar_causa = (Button) v;
this.cxt = v.getContext();
AlertDialog.Builder mensagem = new AlertDialog.Builder(cxt);
final String[] lista = {"Facebook", "Outros"}; //"Denuncia Causa"
mensagem.setTitle("Compartilhar com:");
mensagem.setItems(lista, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
switch (item) {
case 0:
postToWall();
break;
case 1:
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is a sample message via Public Intent");
//startActivity(Intent.createChooser(sendIntent, "Como deseja compartilhar:")); - Estava gerando excessão e troquei por isso abaixo
cxt.startActivity(sendIntent); - Agora ele abre o AlertDialog e assim mesmo da erro na app
break;
case 7:
finish();
}
}
});
mensagem.show();
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.






0 comentários:
Postar um comentário