Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 20
Registered: ‎05-21-2012
My Device: NA
My Carrier: NA

Re: twitter integration with my app -

sir solve this problem.because same message is not posted twice in twitter.

sir i am very thankful to you.

thanking you.

Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
My Carrier: Airtel

Re: twitter integration with my app -

[ Edited ]

Welcome Praveen,

Please press this thread as Solution . If you have done your problem.

Pawan

Contributor
Posts: 20
Registered: ‎05-21-2012
My Device: NA
My Carrier: NA

Re: twitter integration with my app -

sir if i use twitter image button and i click image button then not open twitter login page and i click device back button then twitter login page open.sir plz solve this problem......

 

code here:-

 

public class Screen_20 extends MainScreen implements FieldChangeListener  {

    
    public Screen_20()

{
        super(NO_VERTICAL_SCROLL);
        buildUi();
    }

    private void buildUi() {
        
        BGVFM vfmBase = new BGVFM(NO_VERTICAL_SCROLL| NO_VERTICAL_SCROLLBAR | USE_ALL_HEIGHT);
        VerticalFieldManager vfmmain = new VerticalFieldManager(NO_VERTICAL_SCROLL | Manager.USE_ALL_HEIGHT | USE_ALL_WIDTH);
        this.getMainManager().setBackground(BackgroundFactory.createBitmapBackground(ScreenConstant.TWINTINSCREEN));
        
        
        FieldChangeListener listener =new FieldChangeListener() {
            
            public void fieldChanged(Field field, int context) {
                
                     }
                
              };
              
              Bitmap startBitmap5 = Bitmap.getBitmapResource("twittericon.png");
              BitmapField bm5 = new BitmapField(startBitmap5,BitmapField.HIGHLIGHT_SELECT | BitmapField.FOCUSABLE )
              {
                
                  protected boolean navigationUnclick(int status, int time)
                  {
                    
                      UiApplication.getUiApplication().pushScreen(new TwitterScreen());
                      
                    return true;
                  
                  
                  
                  }
                    
                        
                    
                
              };
              bm5.isFocus();
              bm5.setChangeListener(listener);
              add(bm5);
              
        vfmmain.add(new LabelField());
        vfmmain.add(new LabelField());
        vfmmain.add(new LabelField());
        vfmmain.add(new LabelField());
        vfmmain.add(new LabelField());
        vfmmain.add(new LabelField());
        vfmmain.add(new LabelField());
        vfmmain.add(new LabelField());
        vfmmain.add(new LabelField());
        vfmmain.add(new LabelField());
        vfmmain.add(new LabelField());
        //vfmmain.add(hfmButton);
        vfmBase.add(vfmmain);
        this.add(vfmBase);        
    }

    protected boolean onSavePrompt() {
        return true;}

    public void fieldChanged(Field field, int context) {
        // TODO Auto-generated method stub
        Dialog dlgLogout = new Dialog(Dialog.D_YES_NO,MessageConstant.CLOSEAPP,Dialog.NO,Bitmap.getPredefinedBitmap(Bitmap.QUESTION),FOCUSABLE);
        int reponse = dlgLogout.doModal();
        if(reponse==Dialog.YES){
            System.exit(0);
        }
    }      

 


public boolean onClose() {
    UiApplication.getUiApplication().pushScreen(new Screen_menu());
    
    return false;}

}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////             
  

import net.rim.device.api.browser.field2.BrowserField;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;

import com.twitterapime.rest.Credential;
import com.twitterapime.rest.TweetER;
import com.twitterapime.rest.UserAccountManager;
import com.twitterapime.search.Tweet;
import com.twitterapime.xauth.Token;
import com.twitterapime.xauth.ui.OAuthDialogListener;
import com.twitterapime.xauth.ui.OAuthDialogWrapper;

public class TwitterScreen extends MainScreen  {

    private final String CONSUMER_KEY ="PP0dvMT5HUni3MZeimX4OQ";
    private final String CONSUMER_SECRET = "hqZiN5zADjTWl1f9qSCAsVmWgagg26VcN3qdDpRMFU";
    private final String CALLBACK_URL ="http://www.rechargestudio.com";
    private LabelField _labelStutus;
    private OAuthDialogWrapper pageWrapper = null;
    ShowAuthBrowser showAuthBrowserScreen;
    public TwitterScreen()
    {
        
        setTitle("Twitter Integration using OAuth");
        
        showAuthBrowserScreen = new ShowAuthBrowser();
        UiApplication.getUiApplication().pushScreen(showAuthBrowserScreen);
        showAuthBrowserScreen.doAuth( null );
    }


    class ShowAuthBrowser extends MainScreen implements OAuthDialogListener
    {
        BrowserField b = new BrowserField();
        
        public ShowAuthBrowser()
        {
            Dialog.alert("1");
            _labelStutus = new LabelField("Your app is being authorize");
            add(_labelStutus );
            add(b);
            pageWrapper = new BrowserFieldOAuthDialogWrapper(b,CONSUMER_KEY,CONSUMER_SECRET,CALLBACK_URL,this);
            pageWrapper.setOAuthListener(this);

        }
        public void doAuth( String pin )
        {
            try
            {
                if ( pin == null )
                {
                    pageWrapper.login();
                }
                else
                {
                    
                    this.deleteAll();
                    add(b);
                    pageWrapper.login( pin );
                }

            }
            catch ( Exception e )
            {
                final String message = "Error loggin Twitter: " + e.getMessage();
                Dialog.alert( message );

            }            
        }


        public void onAccessDenied(String response ) {
            
            System.out.println("Access denied! -> " + response );
            updateScreenLog( "Acceso denegado! -> " + response );

        }

        public void onAuthorize(final Token token) {
            
            final Token myToken = token;
    
            UiApplication.getUiApplication().invokeLater( new Runnable() {

                public void run() {
                    deleteAll();
                    doTweet("http://www.rechargestudio.com", token);
                    Dialog.alert( "Tweet succusfully..." );
                    close();
                }
            });

        }

        public void onFail(String arg0, String arg1) {

            updateScreenLog("Error authenticating user! -> " + arg0 + ", " + arg1);

        }

    }


    private void updateScreenLog( final String message )
    {
        UiApplication.getUiApplication().invokeLater( new Runnable() {

            public void run() {
                
                _labelStutus.setText( message );                
            }
        });
    }

    public void doTweet( String message, Token token )
    {
        Credential c = new Credential(CONSUMER_KEY,    CONSUMER_SECRET, token);
        UserAccountManager uam = UserAccountManager.getInstance(c);
        
        try
        {
            if (uam.verifyCredential())
            {
                TweetER.getInstance(uam).post(new Tweet( message ));
                updateScreenLog("Tweet posted!");
            }
        }
        catch (Exception e)
        {
            Dialog.alert("Error by posting tweet."+e.getMessage());
            updateScreenLog("Error by posting tweet.");
        }
    }
}

           
              
              
              
              
              
              
              
              
             

 

Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
My Carrier: Airtel

Re: twitter integration with my app -

Hi Praveen,

You image button is clickable?

Thanks
Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
My Carrier: Airtel

Re: twitter integration with my app -

Hi Praveen,

If you want an image should be clickable then, try this link.

http://supportforums.blackberry.com/t5/Java-Development/Click-on-bitmapfield-image/m-p/1721281#M1991...

Thanks
Pawan
Contributor
Posts: 20
Registered: ‎05-21-2012
My Device: NA
My Carrier: NA

Re: twitter integration with my app -

sir clickable means.......

sir image button is clickable and when i click on twitter image button then no login page is opened.but when i click device back button tnen login page open.sir plz go to my code.....

 

 

thankyou

 

praveen

Contributor
Posts: 20
Registered: ‎05-21-2012
My Device: NA
My Carrier: NA

Re: twitter integration with my app -

sir image button is also clickable.and other activity is also performed but login page not opened.

Contributor
Posts: 20
Registered: ‎05-21-2012
My Device: NA
My Carrier: NA

Re: facebook integration with my app -

sir one problem is there......

 

my blackberry to facebook login is complete.and i post message on my wall, but i want, i click on facebook button then my application is direct like.sir please help me....

 

thankyou

 

praveen