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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:07:26+00:00 2026-05-29T04:07:26+00:00

My current activity class TimerAct.java makes use of a timer of 30secs. Upon the

  • 0

My current activity class “TimerAct.java” makes use of a timer of 30secs. Upon the completion of the timer a new activity “SMS.java” must be initiated. For this, in onFinish() i call a method of my current activity that starts the new activity. But i get a msg to “Force Close”. Can anyone help me out?

Here’s the code:

//TimerAct.java
public class TimerAct extends Activity
{
    static TextView timeDisplay;
    Timer t;
    int length = 30000;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.time);

        timeDisplay = (TextView) findViewById(R.id.timer);
        timeDisplay.setText("Time left: " + length / 1000);
        t = new Timer(length, 1000);
        t.start();
    }   

    public void mess()
    {
        Intent i = new Intent(this, SMS.class);
        startActivity(i);
    }
}

//Timer.java
public class Timer extends CountDownTimer
{
    public Timer(long millisInFuture, long countDownInterval)
    {
        super(millisInFuture, countDownInterval);
    }

    public void onTick(long millisUntilFinished)
    {
        TimerAct.timeDisplay.setText("Time left: " + millisUntilFinished / 1000);
    }

    public void onFinish()
    {
        TimerAct.timeDisplay.setText("Time over!!!");
        TimerAct ta = new TimerAct();
        ta.mess();
    }
}

//SMS.java
public class SMS extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        Intent sendIntent = new Intent(Intent.ACTION_VIEW);
        sendIntent.setType("vnd.android-dir/mms-sms");
        startActivity(sendIntent);

        String phoneNo = "9791192196";
        String message = "Hello";

        sendSMS(phoneNo, message);
    }

    //---sends an SMS message to another device---
    private void sendSMS(String phoneNumber, String message)
    {        
        PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this, SMS.class), 0);
        SmsManager sms = SmsManager.getDefault();
        sms.sendTextMessage(phoneNumber, null, message, pi, null);        
    }
}
  • 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-29T04:07:27+00:00Added an answer on May 29, 2026 at 4:07 am

    In

    public void onFinish()
    

    Use something like:

            Intent fIntent = new Intent();
            fIntent.setClassName("com.pkgname", "com.pkgname.SMSActivity");
            startActivity(fIntent);    
    

    Edit/Update:

    You don’t need to extend a new CountDowntimer in a new class, you can directly override its methods which are required here.
    You can have something like this as a member of class..

    private CountDownTimer myTimer = new CountDownTimer(30000, 1000) {
    //This will give you 30 sec timer with each tick at 1 second
    
        public void onTick(long millisUntilFinished) {
            timeDisplay.setText("Time left: " + length / 1000);
        }
    
        public void onFinish() {
            timeDisplay.setText("Time over!!!");
            Intent fIntent = new Intent();
            fIntent.setClassName("com.pkgname", "com.pkgname.SMSActivity");
            startActivityForResult(fIntent,0);    
        }
     };
    

    with this in onCreate() :

        TextView timeDisplay = (TextView) findViewById(R.id.timer);
        myTimer.start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Intent nnn = new Intent(Hello.this, NewActivity.class); startActivity(nnn); finish(); This would start a new activity,
In my activity I respond to an onClick() by replacing the current view with
Class Activity{ private int level; private Activity predecessor; } My program creates instances of
Assuming i want to open another activity from my current activity and i want
i have executed the following code public class Activity_Threads_Handler extends Activity { private int
I am trying to pass a reference of the current activity to an object
So, I konw that it is possible to kill the current activity and launch
I want to change the current activity to another activity in android using a
I've been trying to load a bitmap in a non-activity class but everything I've
I'm curious about one thing. How can I finish my current activity and start

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.