Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/309.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
Java btn.performClick()无法帮助自动触发按钮_Java_Android - Fatal编程技术网

Java btn.performClick()无法帮助自动触发按钮

Java btn.performClick()无法帮助自动触发按钮,java,android,Java,Android,我想在OTP到达并在edittext区域字段中设置后立即触发一个按钮。OTP设置成功,但提交按钮本身未触发。我错在哪里?这是我的密码 OTP.java package com.nrb.app.nrb.otp; import android.annotation.SuppressLint; import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; impor

我想在OTP到达并在edittext区域字段中设置后立即触发一个按钮。OTP设置成功,但提交按钮本身未触发。我错在哪里?这是我的密码

OTP.java

package com.nrb.app.nrb.otp;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextWatcher;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.nrb.app.nrb.HomeScreen;
import com.nrb.app.nrb.QRresponse.MyDBHelper;
import com.nrb.app.nrb.QRresponse.ServiceCalls;
import com.nrb.app.nrb.QRscanapi.RM;
import com.nrb.app.nrb.R;
import com.nrb.app.nrb.intera.AsyncResponseActivity;
import com.nrb.app.nrb.intera.ConnectionDetectorActivity;
 import com.nrb.app.nrb.login.RegisterValidation;
import com.nrb.app.nrb.login.SignInActivity;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Set;

   import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;


public class OTP extends FragmentActivity implements View.OnClickListener {

private Hashtable<String, String> verifiedResponseKeyValue = new Hashtable<String, String>();
private Hashtable<String, String> verifiedNestedResponseKeyValue = new Hashtable<String, String>();
private String userMobValue;
private String otpVerUrl;
private String userNameValue;
private String userEmailValue;
private String userCountryValue;
private String userId;
private MyDBHelper myDBHelper;
private String userCountryCode;
private boolean timeOut;
static EditText OtpNumber;
private ConnectionDetectorActivity cd;
private String user_exist;
private Button OTP;
Context cntx;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_otp);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    cntx=this;
    OtpNumber = (EditText) findViewById(R.id.etOTPVerifaction);
    cd = new ConnectionDetectorActivity(OTP.this);
    Bundle bundle = getIntent().getExtras();
    userId=bundle.getString("id");
    userEmailValue = bundle.getString("userEmailValue");
    userMobValue = bundle.getString("userMobValue");
    userNameValue = bundle.getString("userNameValue");
    userCountryValue = bundle.getString("userCountryValue");
    userCountryCode = bundle.getString("userCountryCode");
    user_exist = bundle.getString("user_exist");
    registerViews();
}

public void registerViews() {
    OtpNumber = (EditText) findViewById(R.id.etOTPVerifaction);
    // TextWatcher would let us check validation error on the fly
    OtpNumber.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
            RegisterValidation.isName(OtpNumber, false);
        }
        public void beforeTextChanged(CharSequence s, int start, int count, int after){}
        public void onTextChanged(CharSequence s, int start, int before, int count){}
    });

  /*  OtpNumber.setOnEditorActionListener(new EditText.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                OTP.performClick();
                return true;
            }
            return false;
        }
    });*/
}

private boolean checkValidation() {
    boolean ret = true;
    if (!RegisterValidation.isName(OtpNumber, true))
    ret = false;
    return ret;
}

@SuppressLint("InflateParams")
private void popUpDialog(String result1, final boolean newuser) {
    // TODO Auto-generated method stub
    AlertDialog.Builder builder = new AlertDialog.Builder(OTP.this);
    // Get the layout inflater
    LayoutInflater inflater = OTP.this.getLayoutInflater();

    View content = inflater.inflate(R.layout.otp_verification_dialog, null);

    TextView tv = (TextView) content.findViewById(R.id.otpAlertMessage1);
    tv.setText(result1);

    builder.setView(content);
    builder.setCancelable(false);
    final AlertDialog alertDialog = builder.create();
    alertDialog.show();
    content.findViewById(R.id.btnOTPAlertOK).setOnClickListener(
            new View.OnClickListener() {

                @Override
                public void onClick(View v) {

                    // TODO Auto-generated method stub
                    alertDialog.dismiss();
                    if (newuser) {
                        Bundle bundle = new Bundle();
                        bundle.putString("defaultFrag", "newUserFrag");
                        Intent i = new Intent(OTP.this, HomeScreen.class);
                        i.putExtras(bundle);
                        startActivity(i);
                        setResult(10);
                        finish();

                    }
                    else{
                        Toast.makeText(cntx, "Please enter Valid OTP", Toast.LENGTH_LONG).show();
                        OtpNumber.setText("");
                    }
                }
            });
}

@SuppressLint("InflateParams")
private void popUpDialogSuccess(Spannable result1) {
    // TODO Auto-generated method stub
    AlertDialog.Builder builder = new AlertDialog.Builder(OTP.this);
    // Get the layout inflater
    LayoutInflater inflater = OTP.this.getLayoutInflater();

    View content = inflater.inflate(R.layout.otp_verification_dialog, null);

    TextView tv = (TextView) content.findViewById(R.id.otpAlertMessage1);
    tv.setText(result1);

    builder.setView(content);
    builder.setCancelable(false);
    final AlertDialog alertDialog = builder.create();
    alertDialog.show();
    content.findViewById(R.id.btnOTPAlertOK).setOnClickListener(
            new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    alertDialog.dismiss();
                    insertUserPfref();
                }

            });
}

public void verifyOTPKEY(View v) {
    if (checkValidation()){

        EditText etOTPVerification = (EditText) findViewById(R.id.etOTPVerifaction);
        RM.OTP_VER_VALUE = etOTPVerification.getText().toString();
        RM.OTP_MOB_VALUE = userMobValue;

        if (user_exist.compareTo("true") == 0)
            RM.OTP_USER_EXIST_VALUE = "true";
        else
            RM.OTP_USER_EXIST_VALUE = "false";

        JSONObject jsonObject = new JSONObject();
        try {

            jsonObject.put(RM.OTP_VER_KEY, RM.OTP_VER_VALUE);
            jsonObject.put(RM.OTP_MOB_KEY, RM.OTP_MOB_VALUE);
            jsonObject.put(RM.OTP_USER_EXIST_KEY, RM.OTP_USER_EXIST_VALUE);
            jsonObject.put(RM.USER_Id_KEY,userId);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            Log.d("==", "========= FAIL TO CREATE JSON ==========");
        }

        ServiceCalls Login = new ServiceCalls(this, RM.OTP_HOST,
                jsonObject.toString(), "Verifying", 0, new AsyncResponseActivity() {

            @Override
            public void myAsyncResponse(String result) {
                // TODO Auto-generated method stub
                Log.d("==", "vvvvvvvvvvvvvvvvvvvvvvvvvvvvv");
                Log.d("====>>>>", result);
                parseOTPRsponseJason(result);
                Log.d("==", "vvvvvvvvvvvvvvvvvvvvvvvvvvvvv");
            }
        });
        if (cd.isConnectingToInternet()) {
            Login.execute(1);

        } else {
            showNetworFailDialog(RM.NO_INTERNET_MSG);
        }
    }
    else{
        Toast.makeText(this, "Please enter OTP", Toast.LENGTH_LONG).show();
    }
}

   @Override
public void onClick(View v) {

}

class MyOTPAsyncTask extends AsyncTask<Void, Void, String> {

    private ProgressDialog dialog;

    @Override
    protected void onPreExecute() {
        // TODO Auto-generated method stub

        super.onPreExecute();
        dialog = new ProgressDialog(OTP.this);
        dialog.setMessage("Authenticating...");
        dialog.show();
    }

    @Override
    protected String doInBackground(Void... params) {
        StringBuilder stringBuilder = new StringBuilder();
        HttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(otpVerUrl);

        try {
            HttpResponse response = httpClient.execute(httpPost);
            HttpEntity entity = response.getEntity();
            InputStream inputStream = entity.getContent();
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
            String line;
            while ((line = reader.readLine()) != null) {
                stringBuilder.append(line);
            }
            inputStream.close();
        } catch (Exception e) {
            timeOut = true;
            Log.d("readJSONFeed", e.getLocalizedMessage());
        }
        return stringBuilder.toString();
    }

    @Override
    protected void onPostExecute(String result) {
        dialog.dismiss();
        // popUpDialog(result);
        if (!timeOut)
            parseOTPRsponseJason(result);
        else
            showNetworFailDialog(RM.REQ_TIMEOUT_MSG);
        Log.d("----->", "      Response     " + result);
    }

}

private void parseOTPRsponseJason(String result) {
    // TODO Auto-generated method stub
    JSONObject json;
    JSONObject nestedJson;
    try {
        json = new JSONObject(result);
        Iterator<String> iter = json.keys();
        while (iter.hasNext()) {
            String key = iter.next();
            Object value = json.get(key);

            if (user_exist.compareTo("true") == 0) {
                if (key.compareTo("responseHash") == 0) {
                    nestedJson = new JSONObject(json.get(key).toString());
                    Iterator<String> nestedIter = nestedJson.keys();
                    while (nestedIter.hasNext()) {
                        String nestedKey = nestedIter.next();
                        Object nestedValue = nestedJson.get(nestedKey);
                        verifiedNestedResponseKeyValue.put(nestedKey,
                                nestedValue.toString());
                    }
                }
            }
            verifiedResponseKeyValue.put(key, value.toString());

        }

    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    try {
        Set<String> hKeys2 = verifiedResponseKeyValue.keySet();
        for (String string : hKeys2) {
            Log.d("====>",
                    string + " ==>" + verifiedResponseKeyValue.get(string));
        }

        String x = verifiedResponseKeyValue.get("success");

        if (x.compareTo("true") == 0) {

            if (user_exist.compareTo("true") == 0) {
                userNameValue = verifiedNestedResponseKeyValue.get("name");
                Spannable wordtoSpan = new SpannableString("HI "
                        + userNameValue + " , Welcome back to Onspot");
                wordtoSpan.setSpan(new ForegroundColorSpan(Color.RED), 3,
                        3 + userNameValue.length(),
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                popUpDialogSuccess(wordtoSpan);
            } else {
                Spannable wordtoSpan = new SpannableString(
                        "Congratulations! " + userNameValue
                        + " , you are successfully registered.");
                wordtoSpan.setSpan(new ForegroundColorSpan(Color.RED), 17,
                        17 + userNameValue.length(),
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                popUpDialogSuccess(wordtoSpan);
            }
        } else
            popUpDialog(
                    verifiedResponseKeyValue.get("responseMessage"), false);

    } catch (Exception e) {
        // TODO Auto-generated catch block
        Log.d("====>", "Exception");
        popUpDialog(RM.CrashError, false);
    }

}

private void insertUserPfref() {
    // TODO Auto-generated method stub

    myDBHelper = new MyDBHelper(OTP.this);
    myDBHelper.getWritableDatabase();

    if (user_exist.compareTo("true") == 0) {

        try {
            myDBHelper.insertRegisteredUser(
                    verifiedNestedResponseKeyValue.get("email"), //
                    verifiedNestedResponseKeyValue.get("mobile_number"),//
                    verifiedNestedResponseKeyValue.get("name"), //
                    verifiedNestedResponseKeyValue.get("country"),
                    //
                    verifiedNestedResponseKeyValue.get("country_code"));

        } catch (Exception e) {
            // TODO Auto-generated catch block
            Log.d("====>", "Exception");
            popUpDialog(RM.CrashError, false);
        }

        Log.d("------>", "Existing USER");
        Log.d("------>", "Existing USER" + user_exist);

    } else {
        myDBHelper.insertRegisteredUser(userEmailValue,//
                userMobValue,//
                userNameValue, //
                userCountryValue,//
                userCountryCode);
        Log.d("------>", "New User");
        Log.d("------>", "New User" + user_exist);
    }

    Log.d("------>", user_exist);
    startActivity(new Intent(OTP.this, HomeScreen.class));
    setResult(10);
    finish();
}



@SuppressLint("InflateParams")
private void showNetworFailDialog(String msg) {
    // TODO Auto-generated method stub
    AlertDialog.Builder builder = new AlertDialog.Builder(OTP.this);
    // Get the layout inflater
    LayoutInflater inflater = OTP.this.getLayoutInflater();
    View content = inflater.inflate(R.layout.network_failure_dialog, null);
    builder.setView(content);
    builder.setCancelable(false);
    final AlertDialog alertDialog = builder.create();
    alertDialog.show();
    TextView tvMsg = (TextView) content.findViewById(R.id.networkFailMsg);
    tvMsg.setText(msg);
    content.findViewById(R.id.btnNetworkFailureOK).setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    alertDialog.dismiss();
                    setResult(10);
                    finish();
                }
            });
}

@Override
public void onBackPressed() {
    Intent i = new Intent(OTP.this, SignInActivity.class);
    startActivity(i);
    setResult(10);
    finish();
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
    return true;
}

@Override
protected void attachBaseContext(Context newBase) {
    super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}

public void recivedSms(String message)
{
    try
    {
        int pos=message.indexOf(':');
        String msg = message.substring(pos + 2);
        OtpNumber.setText(msg);
        OTP = (Button) findViewById(R.id.btnOTPVerify);
        OTP.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Do something in response to button click
            }
        });
        OTP.performClick();
        OTP.setPressed(true);
  /*      if(OtpNumber!=null) {
            if (checkValidation()) {

                EditText etOTPVerification = (EditText) findViewById(R.id.etOTPVerifaction);
                RM.OTP_VER_VALUE = etOTPVerification.getText().toString();
                RM.OTP_MOB_VALUE = userMobValue;

                if (user_exist.compareTo("true") == 0)
                    RM.OTP_USER_EXIST_VALUE = "true";
                else
                    RM.OTP_USER_EXIST_VALUE = "false";

                JSONObject jsonObject = new JSONObject();
                try {

                    jsonObject.put(RM.OTP_VER_KEY, RM.OTP_VER_VALUE);
                    jsonObject.put(RM.OTP_MOB_KEY, RM.OTP_MOB_VALUE);
                    jsonObject.put(RM.OTP_USER_EXIST_KEY, RM.OTP_USER_EXIST_VALUE);
                    jsonObject.put(RM.USER_Id_KEY, userId);
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    Log.d("==", "========= FAIL TO CREATE JSON ==========");
                }

                ServiceCalls Login = new ServiceCalls(this, RM.OTP_HOST,
                        jsonObject.toString(), "Verifying", 0, new AsyncResponseActivity() {

                    @Override
                    public void myAsyncResponse(String result) {
                        // TODO Auto-generated method stub
                        Log.d("==", "vvvvvvvvvvvvvvvvvvvvvvvvvvvvv");
                        Log.d("====>>>>", result);
                        parseOTPRsponseJason(result);


                        Log.d("==", "vvvvvvvvvvvvvvvvvvvvvvvvvvvvv");
                    }
                });
                if (cd.isConnectingToInternet()) {
                    Login.execute(1);

                } else {
                    showNetworFailDialog(RM.NO_INTERNET_MSG);
                }
            } else {
                Toast.makeText(this, "Please enter OTP", Toast.LENGTH_LONG).show();
            }
        }*/
    }
    catch (Exception e)
    {

    }
}
}
package com.nrb.app.nrb.otp;
导入android.annotation.SuppressLint;
导入android.app.AlertDialog;
导入android.app.ProgressDialog;
导入android.content.Context;
导入android.content.Intent;
导入android.content.pm.ActivityInfo;
导入android.graphics.Color;
导入android.os.AsyncTask;
导入android.os.Bundle;
导入android.support.v4.app.FragmentActivity;
导入android.text.Editable;
导入android.text.Spannable;
导入android.text.SpannableString;
导入android.text.TextWatcher;
导入android.text.style.ForegroundColorSpan;
导入android.util.Log;
导入android.view.LayoutInflater;
导入android.view.MotionEvent;
导入android.view.view;
导入android.view.inputmethod.InputMethodManager;
导入android.widget.Button;
导入android.widget.EditText;
导入android.widget.TextView;
导入android.widget.Toast;
导入com.nrb.app.nrb.HomeScreen;
导入com.nrb.app.nrb.QRresponse.MyDBHelper;
导入com.nrb.app.nrb.QRresponse.ServiceCalls;
导入com.nrb.app.nrb.QRscanapi.RM;
导入com.nrb.app.nrb.R;
导入com.nrb.app.nrb.intera.AsyncResponseActivity;
导入com.nrb.app.nrb.intera.ConnectionDetectorActivity;
导入com.nrb.app.nrb.login.RegisterValidation;
导入com.nrb.app.nrb.login.signianctivity;
导入org.apache.http.HttpEntity;
导入org.apache.http.HttpResponse;
导入org.apache.http.client.HttpClient;
导入org.apache.http.client.methods.HttpPost;
导入org.apache.http.impl.client.DefaultHttpClient;
导入org.json.JSONException;
导入org.json.JSONObject;
导入java.io.BufferedReader;
导入java.io.InputStream;
导入java.io.InputStreamReader;
导入java.util.Hashtable;
导入java.util.Iterator;
导入java.util.Set;
进口uk.co.chrisjenx.书法.CalligraphyContextWrapper;
公共类OTP扩展FragmentActivity实现View.OnClickListener{
私有哈希表verifiedResponseKeyValue=新哈希表();
私有哈希表verifiedNestedResponseKeyValue=新哈希表();
私有字符串userMobValue;
私有字符串otpVerUrl;
私有字符串userNameValue;
私有字符串userEmailValue;
私有字符串userCountryValue;
私有字符串用户标识;
私人MyDBHelper MyDBHelper;
私有字符串userCountryCode;
私有布尔超时;
静态编辑文本OtpNumber;
专用连接检测器活动cd;
私有字符串用户_存在;
专用按钮OTP;
上下文cntx;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_otp);
setRequestedOrientation(ActivityInfo.SCREEN\u ORIENTATION\u Picture);
cntx=这个;
OtpNumber=(EditText)findViewById(R.id.etotpVerification);
cd=新连接检测活动(OTP.this);
Bundle Bundle=getIntent().getExtras();
userId=bundle.getString(“id”);
userEmailValue=bundle.getString(“userEmailValue”);
userMobValue=bundle.getString(“userMobValue”);
userNameValue=bundle.getString(“userNameValue”);
userCountryValue=bundle.getString(“userCountryValue”);
userCountryCode=bundle.getString(“userCountryCode”);
user_exist=bundle.getString(“user_exist”);
registerViews();
}
public void registerViews(){
OtpNumber=(EditText)findViewById(R.id.etotpVerification);
//TextWatcher会让我们随时检查验证错误
OtpNumber.addTextChangedListener(新的TextWatcher(){
公共无效后文本已更改(可编辑){
RegisterValidation.isName(OtpNumber,false);
}
public void beforeTextChanged(字符序列s、int start、int count、int after){}
public void onTextChanged(字符序列,int start,int before,int count){}
});
/*OtpNumber.setOnEditorActionListener(新的EditText.OnEditorActionListener(){
@凌驾
公共布尔onEditorAction(TextView v、int actionId、KeyEvent事件){
if(actionId==EditorInfo.IME\u ACTION\u DONE){
OTP.performClick();
返回true;
}
返回false;
}
});*/
}
私有布尔检查验证(){
布尔ret=真;
如果(!RegisterValidation.isName(OtpNumber,true))
ret=假;
返回ret;
}
@SuppressLint(“充气参数”)
私有void popUpDialog(字符串result1,最终布尔值newuser){
//TODO自动生成的方法存根
AlertDialog.Builder=新建AlertDialog.Builder(OTP.this);
//找到布局充气机
LayoutInflater充气机=OTP.this.getLayoutInflater();
查看内容=充气机。充气(R.layout.otp\u验证\u对话框,空);
TextView tv=(TextView)content.findViewById(R.id.otpAlertMessage1);
tv.setText(result1);
builder.setView(内容);
builder.setCancelable(false);
final AlertDialog AlertDialog=builder.create();
alertDialog.show();
content.findviewbyd(R.id.btnOTPAlertOK).setOnClickListener(
新建视图。OnClickListener(){
@凌驾
公共void onClick(视图v){
//TODO自动生成的方法存根
alertDialog.disclose();
如果(新用户){
Bundle=新Bundle();
bundle.putString(“defaultFrag”、“newUserFrag”);
意向i=新意向(OTP.this,主屏幕.class);
i、 putExtras(束);
星触觉(i);
设定结果(10);
完成();
}
否则{
Toast.makeText(cntx,“请输入有效的OTP”,Toast.LENGTH_LONG.show();
OtpNumber.setText(“”);
}
}
package com.nrb.app.nrb.otp;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
import android.util.Log;

/**
 * Created by Neha on 07-03-2016.
 */
public class IncomingMsg extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent)
    {
        final Bundle bundle = intent.getExtras();
        try {
            if (bundle != null)
            {
                final Object[] pdusObj = (Object[]) bundle.get("pdus");
                for (int i = 0; i < pdusObj.length; i++)
                {
                    SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i]);
                    String phoneNumber = currentMessage.getDisplayOriginatingAddress();
                    String senderNum = phoneNumber ;
                    String message = currentMessage.getDisplayMessageBody();
                    try
                    {
                        if (senderNum.equals("DZ-Onspot"))
                        {
                            OTP Sms = new OTP();
                            Sms.recivedSms(message );
                        }
                    }
                    catch(Exception e){}
                }
            }
        } catch (Exception e)
        {

        }
    }
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ripple="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="25dp"
android:gravity="center"
android:orientation="vertical"
android:background="#fff"
android:padding="10dp" >

     <ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/onspot" />

   <EditText
    android:id="@+id/etOTPVerifaction"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="25dp"
    android:inputType="textCapCharacters"

    android:ems="10"
    android:hint="Enter Verification Key"
    android:maxLength="10"
    android:singleLine="true">

</EditText>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp"
    android:gravity="center_horizontal"
    android:orientation="horizontal"
    android:padding="5dp"
    android:onClick="verifyOTPKEY">

    <com.andexert.library.RippleView
        android:id="@+id/ripple1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:rv_rippleDuration="200"
        app:rv_type="rectangle" >

        <Button
            android:id="@+id/btnOTPVerify"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/button_shadow"
            android:text="SUBMIT"
             android:onClick="verifyOTPKEY"
            android:textColor="@color/white" />
    </com.andexert.library.RippleView>
    </LinearLayout>

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp"
     android:onClick="verifyOTP"
    android:text="Enter Verification key For Login"
    android:textAppearance="?android:attr/textAppearanceSmall" />
 OTP.setOnClickListener(new View.OnClickListener() {
     public void onClick(View v) {
         // Do something in response to button click
     }
 });
OTP.post(new Runnable(){
            @Override
            public void run() {
                 OTP.performClick();
            }
      });
ViewTreeObserver vt = OTP.getViewTreeObserver();
vt.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
    @Override
    public void onGlobalLayout() {
        vt.removeOnGlobalLayoutListener(this);
        OTP.performClick();
    }
});