在phonegap上的skydrive应用程序

时间:2012-11-06 12:17:44

标签: android cordova onedrive

我们正在尝试使用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();
    }
}

此处显示活动但不显示登录页面,该登录页面应作为登录功能的结果显示

0 个答案:

没有答案