激活,数据存储,吐司
激活android
Activity
本質(zhì)上就是UI,一個(gè)應(yīng)用會(huì)包含多個(gè)activity,每個(gè)活動(dòng)包含多個(gè)視圖
public?class?activity1?extends?Activity{
public?void?onCreate(Bundle?icicle){
super.onCreate(icicle);
setContentView(R.layout.main);
}
}
Android開(kāi)發(fā)環(huán)境
1、打電話
Intent?intent?=?new?Intent();
Intent.setAction(Intent.Action);
intent.setData(Uri.parse("tel:"+phoneNo));
在清單文件中要有:
<uses-permission?android:name="android.permission.CALL_PHONE">
2、發(fā)送短信
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>
<!--?儀器,樂(lè)器,工具,測(cè)試?-->
<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);
}
}
數(shù)據(jù)存儲(chǔ)
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
默認(rèn)文件位置:/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();
?
總結(jié)
以上是生活随笔為你收集整理的激活,数据存储,吐司的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 辣条的家常做法?
- 下一篇: 排骨、黑鱼、玉米、冬瓜能一块炖汤吗?