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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:30:44+00:00 2026-05-29T05:30:44+00:00

I know that similar questions have been asked, but having read through them it

  • 0

I know that similar questions have been asked, but having read through them it seems a wide array of things can be done wrong to cause this issue. And with this being my first real Android (and Java) application, I’ve probably done most of them. Thanks in advance for your help!

Stack (Logcat decided to randomly stop working in eclipse for some reason)

Thread [<1> main] (Suspended (exception NullPointerException))  
GMSerial_CleanActivity(Activity).startActivityForResult(Intent, int) line: 3190 
GMSerial_CleanActivity(Activity).startActivity(Intent) line: 3297   
GMSerial_CleanActivity.output(String, String, String, TextView) line: 49    
GMSerial_CleanActivity$1.onCheckedChanged(CompoundButton, boolean) line: 35 
ToggleButton(CompoundButton).setChecked(boolean) line: 125  
ToggleButton.setChecked(boolean) line: 72   
ToggleButton(CompoundButton).toggle() line: 87  
ToggleButton(CompoundButton).performClick() line: 99    
View$PerformClick.run() line: 14105 
ViewRootImpl(Handler).handleCallback(Message) line: 605 
ViewRootImpl(Handler).dispatchMessage(Message) line: 92 
Looper.loop() line: 137 
ActivityThread.main(String[]) line: 4424    
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
Method.invoke(Object, Object...) line: 511  
ZygoteInit$MethodAndArgsCaller.run() line: 784  
ZygoteInit.main(String[]) line: 551 
NativeStart.main(String[]) line: not available [native method]  

Main Code

package com.greymatterrobotics.gmserial;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ToggleButton;
import android.widget.TextView;
import android.widget.EditText;
import android.widget.CheckBox;
import android.widget.CompoundButton;



public class GMSerial_CleanActivity extends Activity {

    static public final char cr = (char) 13;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        final GMSerial_CleanActivity GMSerial = new GMSerial_CleanActivity();
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        ToggleButton toggleSend = (ToggleButton) findViewById(R.id.toggleSend);
        final TextView textLog = (TextView) findViewById(R.id.textLog);
        final EditText editBaud = (EditText) findViewById(R.id.editBaud);
        final EditText editDelay = (EditText) findViewById(R.id.editDelay);
        //final CheckBox checkInvert = (CheckBox) findViewById(R.id.checkInvert);

        toggleSend.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked){
                    GMSerial.output(editBaud.getText().toString(), "Hello World", editDelay.getText().toString(), textLog);
                }

            }
        });

    }

    public void output(String baud, String data, String delay, TextView log) {
        Intent serialout = new Intent();
        serialout.setClassName("com.greymatterrobotics.gmserial", "com.greymatterrobotics.gmserial.Output");
        serialout.putExtra("BAUD", baud);
        serialout.putExtra("DATA", data);
        serialout.putExtra("CHD", delay);
        startActivity(serialout);
        log.setText(log.getText().toString() + cr + data);
    }
}

Output Code (By spiritplumber[at]gmail.com)

package com.greymatterrobotics.gmserial;

import android.app.Activity;
import android.os.Bundle;
import android.os.SystemClock;

public class Output extends Activity {

    static public final char cr = (char) 13; // because i don't want to type that in every time
    static public final char lf = (char) 10; // because i don't want to type that in every time
    public String datatosend = "";


    @Override
    public void onCreate(Bundle savedInstanceState) {
        AudioSerialOutMono.activate();
        try{
            Bundle bundle = getIntent().getExtras();
            if (bundle.containsKey("BAUD"))
                AudioSerialOutMono.new_baudRate = Integer.parseInt(bundle.getString("BAUD"));
            if (bundle.containsKey("CHD"))
                AudioSerialOutMono.new_characterdelay = Integer.parseInt(bundle.getString("CHD"));
            if (bundle.containsKey("DATA"))
                datatosend = (bundle.getString("DATA"));
            AudioSerialOutMono.UpdateParameters(true);
            AudioSerialOutMono.output(datatosend+cr+lf);

            while (AudioSerialOutMono.isPlaying())
            {
                SystemClock.sleep(50);
            }
        }catch(Exception e){e.printStackTrace();}


//      android.os.Process.killProcess(android.os.Process.myPid()); // NUKE
        super.onCreate(savedInstanceState);
        this.finish();
    }
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.greymatterrobotics.gmserial"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="3" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".GMSerial_CleanActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".Output"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
        </activity>
    </application>

</manifest>
  • 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-29T05:30:47+00:00Added an answer on May 29, 2026 at 5:30 am

    The life cycle of an Activity in Android is handled automatically by the system. I mean ,you should not create a new instance of the GMSerial_CleanActivity Activity. You should call the output method directly. Don’t call GMSerial.output.

    Also, in the output method, I prefer to using the code below to start a new activity(your code snippet may be right. I dont’ have Eclipse on hand and thus can’t test it).

    Intent serialout = new Intent();
        serialout.setClass(this, Output.Class);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that similar questions have been asked before, but I am very much
I know that similar questions have been asked all over the place, but I'm
I know similar questions have been asked, e.g. here , but having done a
I know similar questions have been asked before, but I can't find one that
I know that similar questions to this have been asked before but after doing
I know that similar questions have already been asked here before, but they all
I know that similar questions have been asked before but the provided answers don't
I know that similar questions have already been asked but I do not understand
I know that similar questions have been asked in the past but mine has
I know that similar questions have been asked before. But I've been searching SO

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.