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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:36:08+00:00 2026-05-26T20:36:08+00:00

I know that the stop method has been deprecated and I am using destroy

  • 0

I know that the stop method has been deprecated and I am using destroy now, but I get this error:

11-09 11:42:28.740: E/AndroidRuntime(1538): FATAL EXCEPTION: main
11-09 11:42:28.740: E/AndroidRuntime(1538): java.lang.NoSuchMethodError: Thread.destroy()
11-09 11:42:28.740: E/AndroidRuntime(1538):     at java.lang.Thread.destroy(Thread.java:600)
11-09 11:42:28.740: E/AndroidRuntime(1538):     at com.rathbones.src.NewslettersActivity.onKeyDown(NewslettersActivity.java:144)
11-09 11:42:28.740: E/AndroidRuntime(1538):     at android.view.KeyEvent.dispatch(KeyEvent.java:1037)
11-09 11:42:28.740: E/AndroidRuntime(1538):     at android.app.Activity.dispatchKeyEvent(Activity.java:2068)
11-09 11:42:28.740: E/AndroidRuntime(1538):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1643)
11-09 11:42:28.740: E/AndroidRuntime(1538):     at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2471)
11-09 11:42:28.740: E/AndroidRuntime(1538):     at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2441)
11-09 11:42:28.740: E/AndroidRuntime(1538):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1735)
11-09 11:42:28.740: E/AndroidRuntime(1538):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-09 11:42:28.740: E/AndroidRuntime(1538):     at android.os.Looper.loop(Looper.java:123)
11-09 11:42:28.740: E/AndroidRuntime(1538):     at android.app.ActivityThread.main(ActivityThread.java:4627)
11-09 11:42:28.740: E/AndroidRuntime(1538):     at java.lang.reflect.Method.invokeNative(Native Method)
11-09 11:42:28.740: E/AndroidRuntime(1538):     at java.lang.reflect.Method.invoke(Method.java:521)
11-09 11:42:28.740: E/AndroidRuntime(1538):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-09 11:42:28.740: E/AndroidRuntime(1538):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-09 11:42:28.740: E/AndroidRuntime(1538):     at dalvik.system.NativeStart.main(Native Method)
11-09 11:42:28.760: W/ActivityManager(59):   Force finishing activity com.rathbones.src/.NewslettersActivity

The application is not crashing, it’s just that I get this error in logcat.

Actually I have a newsletter module which enables users to view the PDF file. When they press the view button it opens up a progress bar and in the same time if someone presses the backbutton it should stop the thread and exit gracefully. It does that but in the log I get the above error.

Here is the code snippet causing this error:

private void viewOnline() {

        if (currentNewsletter == null) {
            Log.e(Constants.APP_NAME, "No newsletter selected");
            return;
        }

        final ProgressDialog d = new ProgressDialog(this);
        d.setMessage("Downloading...");
        d.show();

        final Context context = getApplicationContext();
         t = new Thread(new Runnable() {
            public void run() {

                String fileName = currentNewsletter.mFilename;

                Log.d(Constants.APP_NAME, "Downloading/showing: " + fileName);
                final File file = Utilities.getFileFromURL(context, currentNewsletter.mUrl, currentNewsletter.mExpectedSizeInBytes, fileName, false);

                d.dismiss();
                // Now we can show the file
                viewPDF(file);
            }
        });
        t.start();

        // Utilities.List(getApplicationContext().getFilesDir().getPath());
        // Utilities.List(getApplicationContext().getDir("files", Context.MODE_WORLD_WRITEABLE).getAbsolutePath());
        // Utilities.DeleteDirectory(getApplicationContext().getDir("files", Context.MODE_WORLD_WRITEABLE).getAbsolutePath());

    }

    private void viewPDF(File file) {

        //DEBUG DEBUG DEBUG
        //Log.d(Constants.APP_NAME, "ViewPDF: showing " + file.getName());
        //Log.d(Constants.APP_NAME, "Path: " + file.getPath());
        //Log.d(Constants.APP_NAME, "Exists: " + file.exists());
        //Log.d(Constants.APP_NAME, "Length: " + file.length());
        //DEBUG DEBUG DEBUG

        // Now it's all safe and sound and local, open it
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(file), "application/pdf");

        try {
            startActivity(intent);
        } catch (Exception e) {
            Toast.makeText(this, "No Application Available to View PDF", Toast.LENGTH_SHORT).show();
        }
    }

    @Override
    protected void onStop() {
        finish();
        super.onStop();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            t.destroy();
           Intent i = new Intent(NewslettersActivity.this,MainMenuActivity.class);

           startActivity(i);
           finish();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
  • 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-26T20:36:08+00:00Added an answer on May 26, 2026 at 8:36 pm

    If you have a thread with a while loop inside, you can control this thread by a boolean flag for the while condition. When you set the flag to false the thread just finishes its task.

    Here’s a little example:

    boolean flag = true;
    Thread secondary = new Thread(new Runnable() {
    
    @Override
    public void run() {
        while (flag) {
        // do something
        }
     }
    });
    
    secondary.start(); //start the thread
    flag = false; // this will force secondary to finish its execution
     try {
       secondary.join(); // wait for secondary to finish
       } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
    

    I will found this code in SO and it also works for me.

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

Sidebar

Related Questions

I know this has been asked before , but I don't think these solutions
I don't know why I started thinking about this, but now I can't seem
The problem is like this: my company has a service that cannot stop running
I know that I can do something like $int = (int)99; //(int) has a
I know that default cron's behavior is to send normal and error output to
I know that |DataDirectory| will resolve to App_Data in an ASP.NET application but is
I know that just using rand() is predictable, if you know what you're doing,
I know that IList is the interface and List is the concrete type but
I know that we shouldn't being using the registry to store Application Data anymore,
I got a vertical testimonials belt and i have this method that animates its

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.