[Resolved] Twitter Issues on Android

I wrote a sample app to test twitter. I want to include it in my app at various places to share high scores.

The problem is my close button does not fire, leaving the web popup on the screen at all times. Is there something wrong with the way that I am calling this? Also will this work on iOS devices?

Here is the code:

[code]
local tweetbttn, tweetbttntext, closebttn, closebttntext

function tweet()
native.showWebPopup( 0,0,320,380,“http://twitter.com/intent/tweet?text=My%20test%20tweet%20goes%20here” )
end

function closeTweet()
native.cancelWebPopup()
end
function main()

tweetbttn = display.newRoundedRect(15, 400, 120, 60, 10)
tweetbttn:setFillColor( 255, 255, 0)
tweetbttntext = display.newText( ‘TWEET’, 30, tweetbttn.y - 10, system.font, 24 )
tweetbttntext:setTextColor ( 255, 0, 0 )
tweetbttn:addEventListener( “touch”, tweet)
closebttn = display.newRoundedRect( 180, 400, 120, 60, 10 )
closebttn:setFillColor( 255, 255, 0)
closebttntext = display.newText(‘CLOSE’, 200, closebttn.y -10 , system.font, 24)
closebttn:addEventListener( “touch”, closeTweet)
closebttntext:setTextColor (255, 0, 0 )
end
main()
[/code] [import]uid: 124716 topic_id: 29410 reply_id: 329410[/import]

Using touch but not specifying an event.phase is firing this more often than intended. Change “touch” (both instances) to “tap” and that should fix the problem.

I believe this should work just fine on iOS devices.

Peach :slight_smile: [import]uid: 52491 topic_id: 29410 reply_id: 118162[/import]

Awesome, I tried that and it worked. I guess I need to be more careful about touch events and including phase to make sure I handle the event on ended. Thanks for the help! [import]uid: 124716 topic_id: 29410 reply_id: 118169[/import]

Not a problem, it’s an easy mistake to make :slight_smile: [import]uid: 52491 topic_id: 29410 reply_id: 118460[/import]

Add a Hashtag to Twitter Link

I discovered you can add the hashtag into the link too.

Before:
[lua]function tweet()
native.showWebPopup( 0,0,320,380,“http://twitter.com/intent/tweet?text=My%20test%20tweet%20goes%20here” )
end[/lua]

After:
[lua]function tweet()
native.showWebPopup( 0,0,320,380,“http://twitter.com/intent/tweet?button_hashtag=TEXTOFTHEHASHTAG&text=My%20test%20tweet%20goes%20here” )
end[/lua]

Directly after the “?” add “button_hashtag=TEXTOFTHEHASHTAG” followed by “&”. Obviously, change
“TEXTOFTHEHASHTAG” to whatever you want the hashtag to be.

EXTRA:
I also found it to work with Local info. If you concatenate like usual [[lua]“something”…reFerence…“theRest”[/lua]], then you can insert a score or whatever into this based on other pieces of your code.

Great Day on the coding front!

Enjoy, Kiffin [import]uid: 80298 topic_id: 29410 reply_id: 123777[/import]

@Kiffin - that is an awesome share! Thank you for posting it :slight_smile: [import]uid: 52491 topic_id: 29410 reply_id: 123847[/import]

Add a Hashtag to Twitter Link

I discovered you can add the hashtag into the link too.

Before:
[lua]function tweet()
native.showWebPopup( 0,0,320,380,“http://twitter.com/intent/tweet?text=My%20test%20tweet%20goes%20here” )
end[/lua]

After:
[lua]function tweet()
native.showWebPopup( 0,0,320,380,“http://twitter.com/intent/tweet?button_hashtag=TEXTOFTHEHASHTAG&text=My%20test%20tweet%20goes%20here” )
end[/lua]

Directly after the “?” add “button_hashtag=TEXTOFTHEHASHTAG” followed by “&”. Obviously, change
“TEXTOFTHEHASHTAG” to whatever you want the hashtag to be.

EXTRA:
I also found it to work with Local info. If you concatenate like usual [[lua]“something”…reFerence…“theRest”[/lua]], then you can insert a score or whatever into this based on other pieces of your code.

Great Day on the coding front!

Enjoy, Kiffin [import]uid: 80298 topic_id: 29410 reply_id: 123777[/import]

@Kiffin - that is an awesome share! Thank you for posting it :slight_smile: [import]uid: 52491 topic_id: 29410 reply_id: 123847[/import]