Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4569958
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:17:37+00:00 2026-05-21T19:17:37+00:00

I have a Textview in my alert dialogue box and i am placing a

  • 0

I have a Textview in my alert dialogue box and i am placing a URL in the text? When i use the following piece of code it gives me an error:

                final TextView message = new TextView(context); 
                final SpannableString s = new SpannableString(context.getText(R.string.SEND_SMS));   
                message.setText(s);
                message.setPadding(10, 0, 4, 0);
                message.setGravity(Gravity.AXIS_CLIP);
                message.setMovementMethod(LinkMovementMethod.getInstance());

                new AlertDialog.Builder(MyClass.this)   
                .setTitle("Message 1\nStep 1 of 4")   
                .setView(message)   
                .setPositiveButton(R.string.CONTINUE,new DialogInterface.OnClickListener() {   
                    public void onClick(DialogInterface dialog, int whichButton) {   

                        Log.e("@@","Inside OnClick");
                        //new CheckLoginStatus().execute();
                        sendSMS();
                        myProgressDialog=new ProgressDialog(MyClass.this);
                        myProgressDialog.setTitle("Message 2\nStep 2 of 4");
                        myProgressDialog.setMessage("Message\n" +
                                "Please wait... attempt "+(count));
                        myProgressDialog.setCancelable(false);
                        myProgressDialog.show();

                        Thread splashTread = new Thread() {
                            @Override
                            public void run() {
                                try {
                                    for(int i=0;i<3;i++)
                                    {
                                        if(!smsStatus || !smsSendStatus){
                                            Log.e("@@","Inside Run..");
                                            int waited = 0;
                                            while( (waited < 120000)) {
                                                sleep(100);
                                                waited += 100;
                                            }
                                            Log.e("after","120sec count="+count);
                                            if(!smsStatus)
                                                handler.sendEmptyMessage(0);
                                        }
                                    }
                                } catch (InterruptedException e) {
                                    e.printStackTrace();
                                }
                                finally
                                {
                                    Log.e("Logs", "Inside stop of thread");
                                    stop();
                                }
                            }
                        };
                        splashTread.start();
                    }   
                })
                .setNegativeButton(R.string.do_later,new DialogInterface.OnClickListener() {   
                    public void onClick(DialogInterface dialog, int whichButton) {   
                        finish();
                    }   
                })
                .setCancelable(false).show();

And the Handler Code is

 private Handler handler = new Handler() {
    public void handleMessage(Message msg) {
        count += 1;
        if(count<=3){
            try{
                Log.e("@@","Inside handler try count="+count);
                if(myProgressDialog.isShowing())
                    myProgressDialog.dismiss();
            }catch(Exception e){
                e.printStackTrace();
            }
            //new CheckLoginStatus().execute();
            sendSMS();
            if(!myProgressDialog.isShowing()){
                myProgressDialog=new ProgressDialog(MyClass.this);
                myProgressDialog.setTitle("My Message\nStep 2 of 4");
                myProgressDialog.setMessage("Me Message\n" +
                        "Please wait... attempt "+(count));
                myProgressDialog.setCancelable(false);
                myProgressDialog.show();
            }
        }else if(count == 4){
            try{
                Log.e("@@","Inside handler else "+count);
                if(myProgressDialog.isShowing())
                    myProgressDialog.dismiss();
            }catch(Exception e){
                e.printStackTrace();
            }
            count = 1;



            final TextView message = new TextView(getBaseContext()); 
            final SpannableString s = new SpannableString(getBaseContext().getText(R.string.SMS_NOT_RECEIVED));
            Linkify.addLinks(s, Linkify.WEB_URLS);
            message.setText(s);
            message.setPadding(10, 0, 4, 0);
            message.setGravity(Gravity.CLIP_HORIZONTAL);
            message.setMovementMethod(LinkMovementMethod.getInstance());  

            new AlertDialog.Builder(MyClass.this)   
            .setTitle("My Message\nError")   
            .setView(message)
            .setPositiveButton(R.string.OK_TEXT,new DialogInterface.OnClickListener() {   
                public void onClick(DialogInterface dialog, int whichButton) {   
                    finish();
                }   
            }).setCancelable(false).show();
        }
    }
};

I think my problem statement is this
Linkify.addLinks(s, Linkify.WEB_URLS);

Earlier it used to work without this statement. Please help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T19:17:38+00:00Added an answer on May 21, 2026 at 7:17 pm

    If your handler is inside an Activity class, then use that class as the context instead of getBaseContext() when creating your TextView.

    That will use the Activity context and make your problem disappear.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code where I create a textLabel. Although I have [textView
I have this piece of code to display an alert dialog when an item
I have the following code for my dialog box, I want to get some
I have a TextView that displays an error message in the login page of
I have a textView and text like This is the Simple Text with KeyWord
I have a TextView which i set the text using setText(). In properties, I
Following is the code I have created for 2 dialog boxes: namely Date Picker
I have TextView. I would like to show text in upper case mode. Is
I have TextView in my app that I want to show text as a
I have textview for which i want to use weight as well as width,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.