Click here to Skip to main content
15,879,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
btnsendsms.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                 phone=edPhone.getText().toString();
                 Intent sentIntent = new Intent(Intent.ACTION_VIEW);
                 sentIntent.putExtra("address", phone);
                 sentIntent.putExtra("sms_body", "Welcome to Sabir Tailors Shinkiari");
                 sentIntent.setType("vnd.android-dir/mms-sms");
                 startActivity(sentIntent);

            }
        });


What I have tried:

when I use this code (new View.OnClickListener() it becomes disabled and when is click on button then is a show error message "unfortunately the project stoped"
in androd studio is shows warning "
Anonymous new View.OnClickListener() can be replaced with lambda
" when is replace it with lambda then same error occure.
Posted
Comments
Richard MacCutchan 14-Aug-21 4:11am    
You will need to do some debugging to find the cause. It is impossible to guess what is going wrong when you run your code.
David Crow 17-Aug-21 19:26pm    
"when I use this code (new View.OnClickListener() it becomes disabled..."

What exactly does that mean? I've not ever known code to disable itself at runtime.

"...when is click on button 0then is a show error message 'unfortunately the project stoped'"

Nothing more in the stack trace?

It's a shot in the dark, but have you cleaned the project? What about invalidating the cache and restarting AS?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900