Linkedin integration onNewIntent() is not called in android Tabs -


i working on app , in tabhost have share setting activity.. integratin twitter, facebook , linkedin in app.. now, have problem in linkedin

 @override  protected void onnewintent(intent intent)  {      log.v("finish", "finish authenticate..");       finishauthenticate(intent.getdata());  } 

is not called because used tabhost. without tabhost working perfectly..

i apply change in manifest file android:launchmode="singletop" , android:launchmode="singletask" android:launchmode="singleinstance" bt it's not working @ all..

following code working perfect me

by following code have done 100% tested

    public class shareinlinkedin extends activity implements onclicklistener {  private linkedinoauthservice oauthservice; private linkedinapiclientfactory factory; private linkedinrequesttoken litoken; private linkedinapiclient client; public static final string linkedin_pref = "gameprefs";  @suppresslint({ "newapi", "newapi", "newapi" }) @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.linkedin);      if (android.os.build.version.sdk_int > 9) {         strictmode.threadpolicy policy = new strictmode.threadpolicy.builder().permitall().build();         strictmode.setthreadpolicy(policy);     }      oauthservice = linkedinoauthservicefactory.getinstance().createlinkedinoauthservice(constants.consumer_key, constants.consumer_secret, constants.scope_params);     system.out.println("oauthservice : " + oauthservice);      factory = linkedinapiclientfactory.newinstance(constants.consumer_key, constants.consumer_secret);      litoken = oauthservice.getoauthrequesttoken(constants.oauth_callback_url);     system.out.println("oncreate:linktourl : " + litoken.getauthorizationurl());     intent = new intent(intent.action_view, uri.parse(litoken.getauthorizationurl()));     startactivity(i);  }  @override protected void onnewintent(intent intent) {     super.onnewintent(intent);      try {         linkedinimport(intent);     } catch (nullpointerexception e) {         e.printstacktrace();     } }  private void linkedinimport(intent intent) {     string verifier = intent.getdata().getqueryparameter("oauth_verifier");     system.out.println("litoken " + litoken);     system.out.println("verifier " + verifier);      linkedinaccesstoken accesstoken = oauthservice.getoauthaccesstoken(litoken, verifier);     //sharedpreferences settings = getsharedpreferences(linkedin_pref, mode_private);     // final editor edit = settings.edit();     // edit.putstring(oauth.oauth_token, accesstoken.gettoken());     // edit.putstring(oauth.oauth_token_secret,     // accesstoken.gettokensecret());     // edit.putstring("linkedin_login", "valid");     // edit.commit();      client = factory.createlinkedinapiclient(accesstoken);      // client.postnetworkupdate("linkedin android app test");      person profile = client.getprofileforcurrentuser(enumset.of(profilefield.id, profilefield.first_name, profilefield.last_name, profilefield.headline));      system.out.println("first name :: " + profile.getfirstname());     system.out.println("last name :: " + profile.getlastname());     system.out.println("head line :: " + profile.getheadline());      oauthconsumer consumer = new commonshttpoauthconsumer(constants.consumer_key, constants.consumer_secret);     consumer.settokenwithsecret(accesstoken.gettoken(), accesstoken.gettokensecret());      defaulthttpclient httpclient = new defaulthttpclient();     httppost post = new httppost("https://api.linkedin.com/v1/people/~/shares");     try {         consumer.sign(post);         post.setheader("content-type", "text/xml");         string myentity = "<share><comment>this test</comment><visibility><code>anyone</code></visibility></share>";         post.setentity(new stringentity(myentity));         org.apache.http.httpresponse response = httpclient.execute(post);         // response         bufferedreader rd = new bufferedreader           (new inputstreamreader(response.getentity().getcontent()));         stringbuffer strbfr = new stringbuffer();            string line = "";         while ((line = rd.readline()) != null) {              strbfr.append(line);         }          system.out.println("response : "+strbfr.tostring());         toast.maketext(shareinlinkedin.this, strbfr.tostring(), toast.length_long).show();     } catch (exception e) {         // todo auto-generated catch block         e.printstacktrace();     }   }  @override public void onclick(view v) {     // todo auto-generated method stub  } 

}

constants.java

    public class constants {  public static final string consumer_key = "your_consumer_key"; public static final string consumer_secret = "your_consumer_secret_key"; public static final string oauth_callback_scheme = "x-oauthflow-linkedin"; public static final string oauth_callback_host = "litestcalback"; public static final string oauth_callback_url = oauth_callback_scheme + "://" + oauth_callback_host; public static final string scope_params = "rw_nus+r_basicprofile"; 

}

androidmanifiest.xml file

      <activity         android:name="com.linkedin.shareinlinkedin"         android:launchmode="singleinstance" >         <intent-filter>             <action android:name="android.intent.action.view" />              <category android:name="android.intent.category.default" />             <category android:name="android.intent.category.browsable" />              <data                 android:host="litestcalback"                 android:scheme="x-oauthflow-linkedin" />         </intent-filter>     </activity> 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -