激活android
Activity
本质上就是UI,一个应用会包含多个activity,每个活动包含多个视图
public class activity1 extends Activity{
public void onCreate(Bundle icicle){
super.onCreate(icicle);
setContentView(R.layout.main);
}
}
Android开发环境
1、打电话
Intent intent = new Intent();
Intent.setAction(Intent.Action);
intent.setData(Uri.parse("tel:"+phoneNo));
在清单文件中要有:
<uses-permission android:name="android.permission.CALL_PHONE">
2、发送短信
SmsManager mng = SmsManager.getDefault();
String msg = "hello";
mng.sendTextMessage("5554",null,msg,null,null);
Toast.makeText(Context,"",1).show();
<uses-permission android:name="android.permission.SEND_SMS" />
注:
Toast通知课可以通知位置
toast.setGravity(Gravity.TOP|Gravity.LEFT,0,0);
Android=吐司处理
toast.setGravity(Gravity.TOP|Gravity.LEFT,0,0);
//自定义吐司
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
//布局文件layout.xml
toast.setView(layout);
toast.show();
<application android:icon="@drawable/icon" package="....">
<uses-library android:name="android.test.runner"/>
.....
</application>
<!-- 仪器,乐器,工具,测试 -->
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="cn.itcast.action"
android:label="Tests for My App" />
public class XMLTest extends AndroidTestCase {
public void testSomething() throws Throwable {
Log.i("Test", "this is test 日志");
System.out.println("ddd");
Assert.assertTrue(1 + 1 == 3);
}
}
数据存储
FileOutputStream fos = context.openFileOutput("itcast.txt",MODE);
MODE:
Context.MODE_PRIVATE = 0
Context.MODE_APPEND = 32768
Context.MODE_WORLD_REANABLE = 1
Context.MODE_WORLD_WRITEABLE = 2
默认文件位置:/data/data/<package name>/files
FileInputStream fis = Context.openFileInput("xxx.txt");
new FileInputStream(new File("/data/data/cn.itcast.xxx/../kk.txt"));
context.getCacheDir();
context.getFilesDir();