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

  • Home
  • SEARCH
  • 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 8988613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:02:32+00:00 2026-06-15T22:02:32+00:00

When I set an activity to be the launcher it works fine, however when

  • 0

When I set an activity to be the launcher it works fine, however when I launch this activity from another activity, it will open fine displaywise, some of the functionality works and some of it does not?! Very confusing for me.

Basically if I open it as the Launcher data can be sent and received over serial. But if I open it from another activity instead absolute crap gets sent over serial and nothing is coming back. However some parts work such as establishing the serial connection?!

In the launching activity this is the code to open the activity I want:

public void openTextTerminal(View view)
{
    Intent intent = new Intent(this, TextBoxActivity.class);
    startActivity(intent);      
}

This is the manifest:
(I don’t think I even need the intent filter?!)

<activity
        android:name="com.example.TextBoxActivity"
        android:label="@string/title_activity_text_box" >

        <intent-filter>
            <action android:name="android.intent.action.TextBoxActivity" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

</activity>

Full Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example"
android:installLocation="auto"
android:versionCode="49"
android:versionName="1.0.48" >

<uses-sdk
    android:minSdkVersion="12"
    android:targetSdkVersion="12" />

<uses-feature
    android:name="android.hardware.touchscreen"
    android:required="false" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<permission
    android:name="com.example.permission.RUN_SCRIPT"
    android:description="@string/permdesc_run_script"
    android:label="@string/perm_run_script"
    android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
    android:protectionLevel="dangerous" />
<permission
    android:name="com.example.permission.APPEND_TO_PATH"
    android:description="@string/permdesc_append_to_path"
    android:label="@string/perm_append_to_path"
    android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
    android:protectionLevel="dangerous" />
<permission
    android:name="com.example.permission.PREPEND_TO_PATH"
    android:description="@string/permdesc_prepend_to_path"
    android:label="@string/perm_prepend_to_path"
    android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
    android:protectionLevel="dangerous" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/application_terminal" >
    <activity
        android:name="com.example.Term"
        android:configChanges="keyboard|keyboardHidden|orientation"
        android:launchMode="singleTask"
        android:theme="@style/Theme"
        android:windowSoftInputMode="adjustResize|stateAlwaysVisible" >
        <intent-filter>
            <action android:name="android.intent.action.TERM" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

    <activity-alias
        android:name="com.example.TermInternal"
        android:exported="false"
        android:targetActivity="Term" >
        <intent-filter>
            <action android:name="com.example.private.OPEN_NEW_WINDOW" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.example.private.SWITCH_WINDOW" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity-alias>

    <activity
        android:name="com.example.RemoteInterface"
        android:excludeFromRecents="true" >
        <intent-filter>
            <action android:name="com.example.OPEN_NEW_WINDOW" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

    <activity-alias
        android:name="com.example.RunScript"
        android:permission="com.example.permission.RUN_SCRIPT"
        android:targetActivity="RemoteInterface" >
        <intent-filter>
            <action android:name="com.example.RUN_SCRIPT" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity-alias>

    <activity
        android:name="com.example.TermPreferences"
        android:label="@string/preferences" />
    <activity
        android:name="com.example.WindowList"
        android:label="@string/window_list" />

    <service android:name="com.example.TermService" />

    <activity
        android:name="com.example.MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.TextBoxActivity"
        android:label="@string/title_activity_text_box" >

        <intent-filter>
            <action android:name="android.intent.action.TextBoxActivity" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

    </activity>
    <activity
        android:name="com.example.SerialTerminalActivity"
        android:label="@string/title_activity_serial_terminal"
        android:screenOrientation="landscape" >
    </activity>
</application>

</manifest>

I replicated the code in a program on it’s own (ie using an activity to launch the second activity without my other unrelated classes) and it works fine. I just copied and pasted. I did a diff on all the files and there is practically nothing different, just unrelated things in the manifest as far as I can see. I’ll just go through the whole manifest tomorrow (I spent a whole day debugging just to find this bug) and rewrite it or something.

I was just curious as to how it can appear that everything is working normally but that it is not. I would have thought once I launch the activity everything is exactly the same no matter how I launch it (as I am passing nothing).

May be passing wrong context, here is full code:

public class MainActivity extends Activity implements OnClickListener,       OnItemSelectedListener, AdapterConnectionListener, DataListener{


private Spinner mBaudSpinner;
private Spinner mDataSpinner;
private Spinner mParitySpinner;
private Spinner mStopSpinner;
private Spinner mDeviceSpinner;
private Button mConnect;
private ArrayList<String> mDeviceOutputs;
private ArrayList<USB2SerialAdapter> mDeviceAdapters;
private ArrayAdapter<CharSequence> mDeviceSpinnerAdapter;
private USB2SerialAdapter mSelectedAdapter;
private TextView mCurrentSettings;

private Button mUpdateSettings;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);

    mConnect = (Button)findViewById(R.id.deviceConnect);
    mConnect.setOnClickListener(this);
    mUpdateSettings = (Button)findViewById(R.id.updateSettings);
    mUpdateSettings.setOnClickListener(this);


    mBaudSpinner = (Spinner)findViewById(R.id.baudSpinner);
    ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mBaudSpinner.setAdapter(adapter);
    String[] tempArray = SlickUSB2Serial.BAUD_RATES;
    for(int i=0;i<tempArray.length;i++) 
    {
        adapter.add(tempArray[i]);
    }
    mBaudSpinner.setSelection(SlickUSB2Serial.BaudRate.BAUD_9600.ordinal());

    mDataSpinner = (Spinner)findViewById(R.id.dataSpinner);
    adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mDataSpinner.setAdapter(adapter);
    tempArray = SlickUSB2Serial.DATA_BITS;
    for(int i=0;i<tempArray.length;i++)
    {
        adapter.add(tempArray[i]);

    }
    mDataSpinner.setSelection(SlickUSB2Serial.DataBits.DATA_8_BIT.ordinal());

    mParitySpinner = (Spinner)findViewById(R.id.paritySpinner);
    adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mParitySpinner.setAdapter(adapter);
    tempArray = SlickUSB2Serial.PARITY_OPTIONS;
    for(int i=0;i<tempArray.length;i++)
    {
        adapter.add(tempArray[i]);

    }
    mParitySpinner.setSelection(SlickUSB2Serial.ParityOption.PARITY_NONE.ordinal());

    mStopSpinner = (Spinner)findViewById(R.id.stopSpinner);
    adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mStopSpinner.setAdapter(adapter);
    tempArray = SlickUSB2Serial.STOP_BITS;
    for(int i=0;i<tempArray.length;i++)
    {
        adapter.add(tempArray[i]);

    }
    mStopSpinner.setSelection(SlickUSB2Serial.StopBits.STOP_1_BIT.ordinal());

    mDeviceAdapters = new ArrayList<USB2SerialAdapter>();
    mDeviceOutputs = new ArrayList<String>();

    mDeviceSpinner = (Spinner)findViewById(R.id.deviceSpinner);
    mDeviceSpinnerAdapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item);
    mDeviceSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mDeviceSpinner.setAdapter(mDeviceSpinnerAdapter);
    mDeviceSpinner.setOnItemSelectedListener(this);

    mCurrentSettings = (TextView)findViewById(R.id.currentSettings);


    SlickUSB2Serial.initialize(this);



}

public void openTerminal(View view) {
    // Do something in response to button
    Intent intent = new Intent(this, Term.class);
    startActivity(intent);
}

public void openTextTerminal(View view) {
    // Do something in response to button
    Intent intent = new Intent(this, TextBoxActivity.class);
    startActivity(intent);

}

public void openSerialTerminal(View view) {
    // Do something in response to button
    Intent intent = new Intent(this, SerialTerminalActivity.class);
    startActivity(intent);

}

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    // TODO Auto-generated method stub
    changeSelectedAdapter(mDeviceAdapters.get(position));
}

@Override
public void onNothingSelected(AdapterView<?> arg0) {
    // TODO Auto-generated method stub
}

public void changeSelectedAdapter(USB2SerialAdapter adapter){
    Toast.makeText(this, "in changeselectedadapter", Toast.LENGTH_SHORT).show();
    //if(mSelectedAdapter!=null){
        //mDeviceOutputs.set(mDeviceSpinnerAdapter.getPosition(mSelectedAdapter.getDeviceId()+""),mReceiveBox.getText().toString());

    mSelectedAdapter = adapter;
    mBaudSpinner.setSelection(adapter.getBaudRate().ordinal());
    mDataSpinner.setSelection(adapter.getDataBit().ordinal());
    mParitySpinner.setSelection(adapter.getParityOption().ordinal());
    mStopSpinner.setSelection(adapter.getStopBit().ordinal());

    updateCurrentSettingsText();

    //mReceiveBox.setText(mDeviceOutputs.get(mDeviceSpinner.getSelectedItemPosition()));
    Toast.makeText(this, "Adapter switched toooo: "+adapter.getDeviceId()+"!", Toast.LENGTH_SHORT).show();
}


@Override
public void onClick(View v) {

    if(v==mConnect){
        SlickUSB2Serial.autoConnect(this);
        if(mSelectedAdapter==null){
            Toast.makeText(this, "no adapters detected", Toast.LENGTH_SHORT).show();
            return;
            //String data = mSendBox.getText().toString() + "\r\n";
        //  mSelectedAdapter.sendData(data.getBytes());
            //mSendBox.setText("");

            }

        Intent intent = new Intent(this, SerialTerminalActivity.class);
        startActivity(intent);
    }


    else if(v==mUpdateSettings){
        if(mSelectedAdapter==null){
            return;
        }

        mSelectedAdapter.setCommSettings(BaudRate.values()[mBaudSpinner.getSelectedItemPosition()],
                DataBits.values()[mDataSpinner.getSelectedItemPosition()],
                ParityOption.values()[mParitySpinner.getSelectedItemPosition()],
                StopBits.values()[mStopSpinner.getSelectedItemPosition()]);

        updateCurrentSettingsText();
        Toast.makeText(this, "Updated Settings", Toast.LENGTH_SHORT).show();

    }

}

@Override
public void onAdapterConnected(USB2SerialAdapter adapter) {
    adapter.setDataListener(this);
    mDeviceAdapters.add(adapter);
    mDeviceOutputs.add("");
    mDeviceSpinnerAdapter.add(""+adapter.getDeviceId());
    mDeviceSpinner.setSelection(mDeviceSpinnerAdapter.getCount()-1);

    Toast.makeText(this, "Adapter: "+adapter.getDeviceId()+" Connected!", Toast.LENGTH_SHORT).show();
    //Toast.makeText(this, "Baud: "+adapter.getBaudRate()+" Connected!", Toast.LENGTH_SHORT).show();
}

@Override
public void onAdapterConnectionError(int error, String msg) {
    // TODO Auto-generated method stub
    if(error==AdapterConnectionListener.ERROR_UNKNOWN_IDS){
        final AlertDialog dialog = new AlertDialog.Builder(this)
        .setIcon(0)
        .setTitle("Choose Adapter Type")
        .setItems(new String[]{"Prolific", "FTDI"}, new   DialogInterface.OnClickListener()
        {
            public void onClick(DialogInterface dialog, int optionSelected){
                if(optionSelected==0)
                    {
                        SlickUSB2Serial.connectProlific(MainActivity.this); 
                    }
                else
                    {
                            SlickUSB2Serial.connectFTDI(MainActivity.this);     
                    }       
            }
        }).create();
        dialog.show();
        return;
    }
    Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
}

private void updateCurrentSettingsText(){
    mCurrentSettings.setText("Current Settings Areeee:     "+mBaudSpinner.getSelectedItem().toString()
            +", "+mDataSpinner.getSelectedItem().toString()
            +", "+mParitySpinner.getSelectedItem().toString()
            +", "+mStopSpinner.getSelectedItem().toString());
    }

@Override
public void onDataReceived(int arg0, byte[] arg1) {
    // TODO Auto-generated method stub
    Toast.makeText(this, "IN ONDATARECIEVED OHOH", Toast.LENGTH_SHORT).show();
}


public void onDestroy() {
    SlickUSB2Serial.cleanup(this);
    super.onDestroy();
}

}
  • 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-15T22:02:33+00:00Added an answer on June 15, 2026 at 10:02 pm

    I found the culprit in onCreate() of the launching activity, it was a library call. All I had to do was move it from the launching activity to the called activity. That will teach me to just follow the API instructions blindly.

    So I had SlickUSB2Serial.initialize(this); in the wrong activity.

    initialize(android.content.Context context) 
    initialize must be called when your app first starts up (in onCreate).
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have my launcher activity flag set to singleTop. when I launch activity from
I want to set some intent flags on the launcher activity of my app
I have a broadcast receiver which will launch an Activity onReceive. When launched, this
The main activity includes some variables with set values. I created a sub-activity with
I have imageView in activity. How I can set position this imageView in my
This is my activity oncreate() method. I set a positive button ok with a
Below is my code from my activity. I call setKey() to set the key,
I realise you can set the LAUNCHER activity of your app in the manifest
I set a custom title bar as example http://coderzheaven.com/2011/06/custom-title-bar-in-android/ , every thing works fine
I'm trying to get content from a textview in another activity to show up

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.