我们正在尝试使用phonegap 访问skydrive。我们使用了一个活动来调用skydrive 的登录功能。但它根本不调用登录功能。
如果有人对此有所了解,那将是很大的帮助。
这是代码。
这里的活动是从 phonegap 的插件类调用的
Intent i = new Intent(myac, DispAct.class);
try{
System.out.println("before start activity");
//i.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
( this.cordova.getActivity()).startActivity(i);
}
catch(Exception e){ System.out.println("in catch"+e);}
下面的代码是被调用的活动
package org.apache.cordova;
import java.util.Arrays;
import android.app.Activity;
import android.os.Bundle;
import com.microsoft.live.LiveAuthClient;
import com.microsoft.live.LiveAuthException;
import com.microsoft.live.LiveAuthListener;
import com.microsoft.live.LiveConnectClient;
import com.microsoft.live.LiveConnectSession;
import com.microsoft.live.LiveStatus;
import com.microsoft.live.R;
public class DispAct extends Activity
{
log obj;
private Object cordova;
private static final String APP_CLIENT_ID ="00000000400D893E" ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
System.out.println("disp on create");
}
@Override
protected void onStart() {
super.onStart();
System.out.println("disp on start");
obj=new log();
obj.auth = new LiveAuthClient(this.getApplicationContext(), APP_CLIENT_ID);
Iterable<String> scopes = Arrays.asList("wl.basic","wl.signin","wl.skydrive","wl.skydrive_update");
obj.auth.login(this,scopes,obj);//********this is the function which has to call login page but does not work
System.out.println("disp after login");
}
@Override
public void onResume()
{
super.onResume();
//finish();
}
}
final class log implements LiveAuthListener{
String type,message;
LiveConnectClient client;
LiveAuthClient auth;
//Parcel out;
public log()
{
//auth=new LiveAuthClient(this, message);
}
synchronized public void onAuthComplete(LiveStatus status, LiveConnectSession session, Object userState) {
if(status == LiveStatus.CONNECTED) {
// this.resultTextView.setText("Signed in.");
System.out.println("IN SUCCess");
client = new LiveConnectClient(session);
//download(0);
notify();
}
else {
//this.resultTextView.setText("Not signed in.");
type="ERROR";
message="Not Connected";
client = null;
System.out.println("IN complete err");
notify();
}
}
synchronized public void onAuthError(LiveAuthException exception, Object userState) {
//this.resultTextView.setText("Error signing in: " + exception.getMessage());
client = null;
//type="ERROR";
//message="Error logging in";
System.out.println("IN error");
notify();
}
}
这里显示了活动,但没有出现登录页面,这应该是登录功能的结果