Wednesday, 2 February 2011

Murdoch Launches the Daily

Internet IconWhile packing up to fly home this morning, I saw the launch for the new "The Daily" online newspaper from News Corp. At launch, TheDaily will only be available for the iPad. Other platforms may be made available at a future date.



The cost. $0.99 a week pay as you go, or $39.95 for sign up for an entire year. This looks like a pretty good pricing system to me. Much cheaper than any print newspaper and a lot cheaper than say the Wall Street Journal ($150 a year for online).



The sections seems to be News, Lifestyle and Entertainment, Sports, and Technology (Games and Apps). Interesting that I didn't see a business section. The would be something I would like.



The actual content looked really rich. Very large and vibrate photos. 360 degree photos. video and audio. In additional there seemed to be all the social media hooks in there. They plan to produce 100 pages of content a day. 7 days a week. The sports section looked killer. Plus you can pick which teams you want to follow.



I think I may give it a try.

Change Android Screen Brightness, LayoutParams.screenBrightness

To change the backlight brightness, LayoutParams.screenBrightness can be used.

WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
layoutParams.screenBrightness = BackLightValue;
getWindow().setAttributes(layoutParams);

This can be used to override the user's preferred brightness of the screen. A value of less than 0, the default, means to use the preferred screen brightness. 0 to 1 adjusts the brightness from dark to full bright.

Change Android Screen Brightness

package com.exercise.AndroidScreenBrightness;

import android.app.Activity;
import android.os.Bundle;
import android.view.WindowManager;
import android.widget.SeekBar;
import android.widget.TextView;

public class AndroidScreenBrightness extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

SeekBar BackLightControl = (SeekBar)findViewById(R.id.backlightcontrol);
final TextView BackLightSetting = (TextView)findViewById(R.id.backlightsetting);

BackLightControl.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(){

@Override
public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
// TODO Auto-generated method stub
float BackLightValue = (float)arg1/100;
BackLightSetting.setText(String.valueOf(BackLightValue));

WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
layoutParams.screenBrightness = BackLightValue;
getWindow().setAttributes(layoutParams);


}

@Override
public void onStartTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub

}

@Override
public void onStopTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub

}});
}
}


main.xml, layout with a SeekBar to change backlight brightness.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Set BackLight of the App"
/>
<SeekBar
android:id="@+id/backlightcontrol"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10px"
android:max="100"
android:progress="50"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/backlightsetting"
android:text="0.50"
/>
</LinearLayout>


Download the files.

next:
- Change system screen brightness, using android.provider.Settings.System.SCREEN_BRIGHTNESS

Tuesday, 1 February 2011

Reading and Writing Files with HTML5

HTML 5 will have an API for reading and writing files. The HTMLRocks site has a tutorial written up on the subject. Currently, the API only works on Chrome 9. More local file storage options for HTML5. Cool stuff.

Implement SensorEventListener to monitor Android light sensor

Last exercise "Get Light Sensor of Android device", this exercise further implement a SensorEventListener to monitor light sensor changed.

SensorEventListener to monitor Android light sensor

package com.exercise.AndroidLightSensor;

import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.TextView;

public class AndroidLightSensor extends Activity {

SensorManager mySensorManager;
Sensor myLightSensor;
TextView textLightSensorData;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView textLightSensor = (TextView)findViewById(R.id.lightsensor);
textLightSensorData = (TextView)findViewById(R.id.lightsensordata);

mySensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
myLightSensor = mySensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);

if (myLightSensor == null){
textLightSensor.setText("No Light Sensor!");
}else{
textLightSensor.setText(myLightSensor.getName());

mySensorManager.registerListener(lightSensorEventListener,
myLightSensor,
SensorManager.SENSOR_DELAY_NORMAL);
}
}

SensorEventListener lightSensorEventListener
= new SensorEventListener(){

@Override
public void onAccuracyChanged(Sensor arg0, int arg1) {
// TODO Auto-generated method stub

}

@Override
public void onSensorChanged(SensorEvent arg0) {
// TODO Auto-generated method stub
if(arg0.sensor.getType()==Sensor.TYPE_LIGHT){
textLightSensorData.setText("Light Sensor Date:"
+ String.valueOf(arg0.values[0]));
}
}};
}


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<TextView
android:id="@+id/lightsensor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/lightsensordata"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>


Download the files.

Monday, 31 January 2011

Using CSS to Style for Web and Mobile

CSS ButtonFound this post on bloop.co on how to style a site for desktop and mobile form factors. One set of CSS handles several different form factors. I can't say I understand all it, but I am excited to learn more. :)



So want to learn what a CSS Media Query is? Check out this tutorial on CSS Tricks.

Get Light Sensor of Android device

Get Light Sensor of HTC wildfire

package com.exercise.AndroidLightSensor;

import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.TextView;

public class AndroidLightSensor extends Activity {

SensorManager mySensorManager;
Sensor myLightSensor;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView textLightSensor = (TextView)findViewById(R.id.lightsensor);

mySensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
myLightSensor = mySensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);

if (myLightSensor == null){
textLightSensor.setText("No Light Sensor!");
}else{
textLightSensor.setText(myLightSensor.getName());
}
}
}


layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<TextView
android:id="@+id/lightsensor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>


Download the files.

Next:
- Implement SensorEventListener to monitor Android light sensor

Sunday, 30 January 2011

Updating How To Pages

While creating the immutability content I realized that my How To templates were a little out of date. So I will be updating all the how to content to new templates over the coming days. Right now, only the Java How To topics have been updated. If you see anything out of whack please let me know. Just comment on this post. Thanks. Mike W.