Click here to Skip to main content
15,870,130 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am making an app which starts an overlay button which stays on top of all other activities when the toggle switch is on .

I have the following three classes with no errors shown in eclipse .

MainActivity class-
Java
public class MainActivity extends ActionBarActivity {
  @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

      if (savedInstanceState == null) {
	getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();
      }
    }
	
    public void openOverlayButton(View view) {
      // Is the toggle on?
      boolean on = ((Switch) view).isChecked();
	    
      if (on) {
        Intent intent = new Intent(this, TaskBarViewNew.class);
	startActivity(intent);
      } else {
	// Disable overlay button
      }

TaskBarViewNew class-

Java
public class TaskBarViewNew extends Activity {
  @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      Intent svc = new Intent(this , OverlayButtonActivity.class);
      startService(svc);
      finish();
   }


And the OverlayBittonActivity is just a service which works fine alone but here it is not working . I think I am doing a mistake in using Intent . Can anyone help??
Posted
Updated 8-Jun-14 0:00am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900