java - Android share a combined string -
i have button action calls share intent. construct string strings.xml
below have strings:
<string name="app_name">nowicons</string> <string name="market">market://details?id=com.nmiltner.nowicon</string>
my string constructor here:
public string share = "check out " + getresources().getstring(r.string.app_name) + getresources().getstring(r.string.market);
by button click here:
btn_share.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { // launching share intent intent sendintent = new intent(); sendintent.setaction(intent.action_send); sendintent.putextra(intent.extra_text, share); sendintent.settype("text/plain"); startactivity(sendintent); } });
when test app, force close, , error log has null pointer exception.
i using similar method send user play store rate app.
public string marketurl = getresources().getstring(r.string.market); btn_rate.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { // go market listing uri uri1 = uri.parse(marketurl); startactivity(new intent(intent.action_view, uri1)); } });
fixed!!!
edit:
i able work out, here fix:
public string marketurl; public string share; btn_rate.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { // go market listing string marketurl = getresources().getstring(r.string.market); uri uri1 = uri.parse(marketurl); startactivity(new intent(intent.action_view, uri1)); } }); btn_share.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { // launching share intent string share = "check out " + getresources().getstring(r.string.app_name) + " " + getresources().getstring(r.string.market) + " on play store"; intent sendintent = new intent(); sendintent.setaction(intent.action_send); sendintent.putextra(intent.extra_text, share); sendintent.settype("text/plain"); startactivity(sendintent); } });
Comments
Post a Comment