私はLinkedIn統合を使用してテキストと画像を共有しているという点で1つのアプリを開発しています.HTCモバイルでは非常にうまく機能していますが、すべてのSamsungモバイルでは機能していません. 私の問題を解決してください
私のJavaコード..
Button b1 = (Button)findViewById(R.id.button1);
b1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(),LinkedInPost.class);
startActivity(i);
}
}
LinkedInPost.java
public class LinkedInPost extends Activity
{
// initializations
public static final String CONSUMER_KEY = "key-key-key";
public static final String CONSUMER_SECRET = "key-key-key";
public static final String OAUTH_CALLBACK_SCHEME = "x-oauthflow-linkedin";
public static final String OAUTH_CALLBACK_HOST = "techgene";
public static final String OAUTH_CALLBACK_URL = OAUTH_CALLBACK_SCHEME + "://" + OAUTH_CALLBACK_HOST;
final LinkedInOAuthService oAuthService = LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(CONSUMER_KEY,CONSUMER_SECRET);
final LinkedInApiClientFactory factory = LinkedInApiClientFactory.newInstance(CONSUMER_KEY, CONSUMER_SECRET);
LinkedInRequestToken liToken;
LinkedInApiClient client;
private String strLinkedInMessage;
private String strLinkTitle;
private String strLink;
//Called when the activity is starting.
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.linkedin);
strLinkedInMessage = "04.17pm";
strLinkTitle = "testing";
strLink = "http://184.173.113.66/images/deal/rest_2012_3_18-0_1_27309-oysters-01.jpg";
liToken = oAuthService.getOAuthRequestToken(OAUTH_CALLBACK_URL);
try
{
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(liToken.getAuthorizationUrl()));
startActivity(i);
}
catch (Exception e)
{
Toast.makeText(getBaseContext(), e.toString(), Toast.LENGTH_SHORT).show();
}
}
/**
* Method to verify the authentication, As it is used only in this package, it is made protected
*/
@Override
protected void onNewIntent(Intent intent)
{
try
{
String verifier = intent.getData().getQueryParameter("oauth_verifier");
LinkedInAccessToken accessToken = oAuthService.getOAuthAccessToken(liToken, verifier);
client = factory.createLinkedInApiClient(accessToken);
client.postShare(strLinkedInMessage, strLinkTitle,strLink, strLink,VisibilityType.CONNECTIONS_ONLY);
Toast.makeText(getBaseContext(), "In Try +ve", Toast.LENGTH_SHORT).show();
}
catch (Exception e)
{
Toast.makeText(getBaseContext(), "onNewIntent", Toast.LENGTH_SHORT).show();
}
finish();
}
マニフェスト.xml
<activity
android:name=".LinkedInPost"
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="techgene"
android:scheme="x-oauthflow-linkedin" />
</intent-filter>
</activity>
このコードは htc では正常に動作しますが、samsung では logcat で動作しません。このようなエラーが発生します
10-02 06:16:07.312: E/AndroidRuntime(11708): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test/com.test.LinkedInPost}: com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceException: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: api.linkedin.com
10-02 06:16:07.312: E/AndroidRuntime(11708): Caused by: com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceException: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: api.linkedin.com
10-02 06:16:07.312: E/AndroidRuntime(11708): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:294)
10-02 06:16:07.312: E/AndroidRuntime(11708): at java.net.InetAddress.lookupHostByName(InetAddress.java:497)
10-02 06:16:07.312: E/AndroidRuntime(11708): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:69)