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 8514507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:53:21+00:00 2026-06-11T04:53:21+00:00

I am newbie android programmer. just started by seeing some online tutorials, i decided

  • 0

I am newbie android programmer. just started by seeing some online tutorials, i decided to make a application for myself.. it was working fine till yesterday.. The only change i made today was to add this line “this.requestWindowFeature(Window.FEATURE_NO_TITLE);” and it stated throwing the error. pls provide the solution for this.

public class MainActivity extends Activity implements OnClickListener, Runnable {
Context context;

EditText editTextNum, editText, editUserName, editPassword;
Button btnsend;
ProgressDialog pd;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);     
    editUserName = (EditText) findViewById(R.id.edit_userName);
    editPassword = (EditText) findViewById(R.id.edit_password);
    editTextNum = (EditText) findViewById(R.id.edit_number);
    editText = (EditText) findViewById(R.id.edit_message);      
    btnsend = (Button) findViewById(R.id.btnsend);
    btnsend.setOnClickListener(this);
}

/** Called when the user clicks the Send button */
public void sendMessage() {
    if (!isOnline()) {
        Toast.makeText(MainActivity.this,"No Internet Access..Cannot Send SMS", Toast.LENGTH_LONG).show();
    } else {
        String userName = editUserName.getText().toString();
        String password = editPassword.getText().toString();
        String number = editTextNum.getText().toString();
        String message = editText.getText().toString();
        String msgreciever = number;
        String testMessage = message;
        try {
            SmsSender.sendMessage(msgreciever, testMessage, userName, password);
        } catch (Exception ex) {
            Toast.makeText(MainActivity.this, "SMS Sending Failed.",Toast.LENGTH_LONG).show();
        }

    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

public boolean isOnline() {
    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netInfo = cm.getActiveNetworkInfo();
    if (netInfo != null && netInfo.isConnectedOrConnecting()) {
        return true;
    }
    return false;
}

public void onClick(View v) {
    // TODO Auto-generated method stub
    if (v == btnsend) {
        if (!isOnline()) {
            Toast.makeText(MainActivity.this,"No Internet Access..Cannot Send SMS",Toast.LENGTH_LONG).show();
        } else {
            pd = ProgressDialog.show(MainActivity.this, "Free Sms","Sending SMS..Please Wait..!!", true);
            Thread t = new Thread(this);
            t.start();
        }

    }
}

public void run() {
    // TODO Auto-generated method stub
    sendMessage();
    mHandler.sendEmptyMessage(0);
}

public Handler mHandler = new Handler() {
    @Override
    public void handleMessage(Message msg) {
        // TODO Auto-generated method stub
        super.handleMessage(msg);
        pd.dismiss();
        Toast.makeText(MainActivity.this, "Message Sent Successfully",Toast.LENGTH_LONG).show();
        editTextNum.setText("");
        editText.setText("");
        editTextNum.requestFocus();
    }
};
}
  • 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-06-11T04:53:22+00:00Added an answer on June 11, 2026 at 4:53 am

    Check out my post which explains the reasons behind this: http://www.levinotik.com/2012/01/10/loopers-handlers-runtimeexceptions-explained/ In short, you need to provide the Handler with a Looper from some thread. You can always get this by doing new Handler(Looper.getMainLooper()):

    Also, you should not be managing your own threads inside of Activities, or at least not usually. What you need to do is create the Handler as I showed and then call mHandler.post(runnable), passing in the runnable you want to run. You are needlessly creating a new Thread just so you can call start on it so the Runnable’s run() method is executed. Why not just have it run directly by having the handler post that runnable?

    So it should look like:

    Handler mHandler = new Handler(Looper.getMainLooper());
    
    Runnable myRunnable = new Runnable() {
     public void run() {work here...}
    }
    
    ...elsewhere
    
    mHandler.post(myRunnable);
    

    In fact, if you do it this way, I’d be surprised if it didn’t work even WITHOUT using Looper.getMainLooper();

    EDIT

    I don’t know what SmsSender is, but that is likely what’s causing you to reach for a new Thread. If SmsSender is doing some long-running work, then what you should do is use an AsyncTask to do that work in the background. Then in onPostExecute you can update your UI with whatevers relevant. You seem to be trying to implement the functionality of AsyncTask yourself, albeit unsuccessfully. See why? You’re trying to do some expensive work in the background and then let the UI update with the status by using a Handler. This is precisely what AsyncTask is meant to help you with, except that it implements all of this correctly and makes it easy for you. 🙂

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

Sidebar

Related Questions

I'm rather newbie on Android, and I'm working on a simple application to get
I'm newbie in Android application development. I just downloaded all SDks and Eclispe. Then
I am a newbie android developer. In some application, mainly Iphone magazine or others,
I'm a newbie programmer android I want to make an android app to record
Android newbie here. I'm using this tutorial to show some rows that I fetch
I am newbie in android. I developed an android application that shows 15 tabs.
Hi am newbie to android development. I had created one application where i need
I am newbie in android. I had planned to develop an application which divides
I am an Android Newbie and I'm developing Go game application for android. I'm
I am newbie to android. I have client server based application. Server keeps on

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.