Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何访问Oauth 1.0??我在做SugarCrm_Android_Android Studio_Oauth_Sugarcrm - Fatal编程技术网

Android 如何访问Oauth 1.0??我在做SugarCrm

Android 如何访问Oauth 1.0??我在做SugarCrm,android,android-studio,oauth,sugarcrm,Android,Android Studio,Oauth,Sugarcrm,大家好,我正在从事一个使用Sugarcrm 6.5版本的CRM项目。我想知道我必须在我的LoginActivity中做什么样的更改才能获得令牌,以便我可以在其他活动中调用它 public class LoginActivity extends AppCompatActivity { private static final String TAG = LoginActivity.class.getSimpleName(); private Button button; private EditT

大家好,我正在从事一个使用Sugarcrm 6.5版本的CRM项目。我想知道我必须在我的LoginActivity中做什么样的更改才能获得令牌,以便我可以在其他活动中调用它

public class LoginActivity extends AppCompatActivity {

private static final String TAG = LoginActivity.class.getSimpleName();
private Button button;
private EditText editText;
private EditText editText2;
private ProgressDialog pDialog;
private SessionManager session;
private SQLiteHandler db;
CheckBox show_password;
String user_fullname, email, user_id,user_mobile, session_id, module;

public LoginActivity(){


}

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    editText = (EditText) findViewById(R.id.editText);
    editText2 = (EditText) findViewById(R.id.editText2);
    button = (Button) findViewById(R.id.button);
    show_password = (CheckBox) findViewById(R.id.show_hide_password);

    // Progress dialog
    pDialog = new ProgressDialog(this);
    pDialog.setCancelable(false);

    // SQLite database handler
    db = new SQLiteHandler(getApplicationContext());

    // Session manager
    session = new SessionManager(getApplicationContext());
    // get the show/hide password Checkbox

    // Check if user is already logged in or not
    //if (session.isLoggedIn()) {
        // User is already logged in. Take him to main activity

      //  Intent intent = new Intent(LoginActivity.this, MainActivity.class);
      //  startActivity(intent);
       // finish();
  //  }
    // Login button Click Event

    show_password.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // checkbox status is changed from uncheck to checked.
            if (!isChecked) {
                // show password
                editText2.setTransformationMethod(PasswordTransformationMethod.getInstance());
            } else {
                // hide password
                editText2.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
            }
        }
    });

    button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {
            String username = editText.getText().toString().trim();
            String password = editText2.getText().toString().trim();

            // Check for empty data in the form
            if (!username.isEmpty() && !password.isEmpty()) {
                // login user
                checkLogin(username, password);
            } else {
                // Prompt user to enter credentials
                Toast.makeText(getApplicationContext(),
                        "Please enter the credentials!", Toast.LENGTH_LONG)
                        .show();
            }
        }

    });
}

/**
 * function to verify login details in mysql db
 */
private void checkLogin(final String username, final String password) {

    pDialog.setMessage("Logging in ...");
    showDialog();

    RequestQueue requestQueue = Volley.newRequestQueue(this);
    String URL= "http://crm.sparshnow.com/api/index.php?username="+username+"&password="+password;
    final JsonObjectRequest strReq = new JsonObjectRequest(URL,null, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            Log.d(TAG, "Login Response: " + response);
            hideDialog();

            try {
                String success = response.getString("success");
                Log.d("response_value", success);
                if (success.equals("TRUE")) {

                    user_fullname=response.getString("user_fullname");
                    email=response.getString("email");
                    user_id=response.getString("user_id");
                    user_mobile=response.getString("user_mobile");
                    session_id=response.getString("session_id");
                    Intent intent = new Intent(LoginActivity.this,
                            MainActivity.class);
                    intent.putExtra("user_fullname",user_fullname);
                    intent.putExtra("email",email);
                    intent.putExtra("user_mobile",user_mobile);
                    intent.putExtra("session_id", session_id);
                    session.setLogin(true);
                    startActivity(intent);
                    finish();
                } else {
                    Toast.makeText(getApplicationContext(), "Enter Correct Detail ", Toast.LENGTH_LONG).show();
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    },

            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError success) {
                    Log.e(TAG, "Login Error: " + success.getMessage());
                    Toast.makeText(getApplicationContext(),
                            success.getMessage(), Toast.LENGTH_LONG).show();
                    hideDialog();
                }
            });
    requestQueue.add(strReq);
}
private void showDialog() {
    if (!pDialog.isShowing())
        pDialog.show();
}

private void hideDialog() {
    if (pDialog.isShowing())
        pDialog.dismiss();
}
}
公共类LoginActivity扩展了AppCompatActivity{
私有静态最终字符串标记=LoginActivity.class.getSimpleName();
私人按钮;
私人编辑文本;
私有编辑文本编辑文本2;
私人对话;
私人会话管理器会话;
私有SQLiteHandler数据库;
复选框显示密码;
字符串user\u fullname、email、user\u id、user\u mobile、session\u id、module;
公共后勤活动(){
}
@凌驾
创建时的公共void(最终捆绑包savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u登录);
editText=(editText)findViewById(R.id.editText);
editText2=(EditText)findViewById(R.id.editText2);
按钮=(按钮)findViewById(R.id.button);
show_password=(复选框)findviewbyd(R.id.show_hide_password);
//进度对话框
pDialog=新建进度对话框(此对话框);
pDialog.setCancelable(假);
//SQLite数据库处理程序
db=新的SQLiteHandler(getApplicationContext());
//会话管理器
session=newsessionmanager(getApplicationContext());
//获取显示/隐藏密码复选框
//检查用户是否已登录
//if(session.isLoggedIn()){
//用户已登录。请将其带到主活动
//意向意向=新意向(LoginActivity.this、MainActivity.class);
//星触觉(意向);
//完成();
//  }
//登录按钮点击事件
show_password.setOnCheckedChangeListener(新建CompoundButton.OnCheckedChangeListener(){
检查更改后的公共无效(复合按钮视图,布尔值已检查){
//复选框状态从未选中更改为已选中。
如果(!已检查){
//显示密码
editText2.setTransformationMethod(PasswordTransformationMethod.getInstance());
}否则{
//隐藏密码
editText2.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
}
}
});
setOnClickListener(新视图.OnClickListener(){
公共void onClick(视图){
字符串username=editText.getText().toString().trim();
字符串密码=editText2.getText().toString().trim();
//检查表单中是否有空数据
如果(!username.isEmpty()&&!password.isEmpty()){
//登录用户
checkLogin(用户名、密码);
}否则{
//提示用户输入凭据
Toast.makeText(getApplicationContext(),
“请输入凭据!”,Toast.LENGTH\u LONG)
.show();
}
}
});
}
/**
*函数验证mysql数据库中的登录详细信息
*/
私有void checkLogin(最终字符串用户名、最终字符串密码){
设置消息(“登录…”);
showDialog();
RequestQueue RequestQueue=Volley.newRequestQueue(this);
字符串URL=”http://crm.sparshnow.com/api/index.php?username=“+username+”&password=“+password;
final JsonObjectRequest strReq=新JsonObjectRequest(URL,null,new Response.Listener()){
@凌驾
公共void onResponse(JSONObject响应){
Log.d(标记“登录响应:”+响应);
hideDialog();
试一试{
String success=response.getString(“success”);
Log.d(“响应值”,成功);
if(success.equals(“TRUE”)){
user_fullname=response.getString(“user_fullname”);
email=response.getString(“email”);
user_id=response.getString(“user_id”);
user_mobile=response.getString(“user_mobile”);
session_id=response.getString(“session_id”);
意向意向=新意向(LoginActivity.this,
主要活动(课堂);
intent.putExtra(“user\u fullname”,user\u fullname);
意向。额外(“电子邮件”,电子邮件);
intent.putExtra(“用户\移动设备”,用户\移动设备);
intent.putExtra(“会话id”,会话id);
session.setLogin(true);
星触觉(意向);
完成();
}否则{
Toast.makeText(getApplicationContext(),“输入正确的细节”,Toast.LENGTH\u LONG.show();
}
}捕获(JSONException e){
e、 printStackTrace();
}
}
},
新的Response.ErrorListener(){
@凌驾
公共错误响应(截击错误成功){
Log.e(标记“登录错误:+success.getMessage());
Toast.makeText(getApplicationContext(),
success.getMessage(),Toast.LENGTH_LONG).show();
hideDialog();
}
});
添加(streq);
}
私有void showDialog(){
如果(!pDialog.isShowing())
pDialog.show();
}
私有void hideDialog(){
if(pDialog.isShowing())
pDialog.disclose();
}
}
一点代码 如何使用它对我来说非常有用。。请帮帮我