I am working through the BigNerdRanch book in order to increase Android proficiency. After days and days of running code and having my screen dim on me I decided to add a command to wake/un-dim the screen so I didn't have to continually reach over and tap the extremely dim power-saving screen in order to check on my program.
This led to a whole slew of Google, StackOverflow, etc searches the most relevant of which I will attach at the bottom of this post. The problem I face now is back to a basic one:
My second activity is not launching and I know that because the break points I have placed at arbitrary points within the code are catching nothing. I have no idea why.
Here is the relevant segment of my launcher activity code:
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragment);
//screen refresher start
android.provider.Settings.System.putInt(getApplicationContext().getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS, 255);
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 255; // 100 / 100f;
getWindow().setAttributes(lp);
Intent k = new Intent(SingleFragmentActivity.this, RefreshScreen.class);
startActivity(k);
//screen refresher end
FragmentManager fm = getSupportFragmentManager();
Fragment fragment = fm.findFragmentById(R.id.fragment_container);
if (fragment == null){
fragment = createFragment();
fm.beginTransaction().add(R.id.fragment_container, fragment).commit();
}
}
Here is the second activity's code
public class RefreshScreen extends Activity {
int x = 5;
protected void OnCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
this.finish();
return;
}
}
I put break points a the following locations:
Always works.
startActivity(k);
Never arrives.
int x = 5;
Never arrives.
super.onCreate(savedInstanceState);
Never arrives.
return;
If for some reason what I was attempting to do would help you, here is the relevant link.
Changing screen brightness programmatically (as with the power widget)