Android中設(shè)置只有程序第一次運(yùn)行才顯示的界面實(shí)現(xiàn)思路
更新時(shí)間:2013年06月03日 16:40:58 作者:
如何實(shí)現(xiàn)程序第一次運(yùn)行才顯示的界面,下面是具體的實(shí)現(xiàn)思路及步驟,有類似需求的朋友可以參考下哈
程序安裝后第一次啟動(dòng):
啟動(dòng)頁(yè)-->功能介紹頁(yè)-->系統(tǒng)主頁(yè)
以后啟動(dòng):
啟動(dòng)頁(yè)-->系統(tǒng)主頁(yè)
所以在啟動(dòng)頁(yè)中判斷一下就可以了
可以弄一個(gè)文件保存一個(gè)狀態(tài),推薦用SharedPreferences。
1.可以定義一個(gè)變量來(lái)判斷程序是第幾次運(yùn)行,如果是第一次則跳轉(zhuǎn)到引導(dǎo)的Activity,如果不是第一次則執(zhí)行系統(tǒng)主頁(yè)。
判斷系統(tǒng)是第一次運(yùn)行的代碼實(shí)現(xiàn)如下:
在Activity中添加代碼:
使用SharedPreferences來(lái)記錄程序的使用次數(shù)
一下是實(shí)現(xiàn)的代碼:
<SPAN style="FONT-SIZE: 18px"><STRONG>public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
preferences = getSharedPreferences("count",MODE_WORLD_READABLE);
int count = preferences.getInt("count", 0);
//判斷程序與第幾次運(yùn)行,如果是第一次運(yùn)行則跳轉(zhuǎn)到引導(dǎo)頁(yè)面
if (count == 0) {
Intent intent = new Intent();
intent.setClass(getApplicationContext(),LaunchGuideViewActivity.class);
startActivity(intent);
this.finish();
}
Editor editor = preferences.edit();
//存入數(shù)據(jù)
editor.putInt("count", ++count);
//提交修改
editor.commit();</STRONG></SPAN>
啟動(dòng)頁(yè)-->功能介紹頁(yè)-->系統(tǒng)主頁(yè)
以后啟動(dòng):
啟動(dòng)頁(yè)-->系統(tǒng)主頁(yè)
所以在啟動(dòng)頁(yè)中判斷一下就可以了
可以弄一個(gè)文件保存一個(gè)狀態(tài),推薦用SharedPreferences。
1.可以定義一個(gè)變量來(lái)判斷程序是第幾次運(yùn)行,如果是第一次則跳轉(zhuǎn)到引導(dǎo)的Activity,如果不是第一次則執(zhí)行系統(tǒng)主頁(yè)。
判斷系統(tǒng)是第一次運(yùn)行的代碼實(shí)現(xiàn)如下:
在Activity中添加代碼:
使用SharedPreferences來(lái)記錄程序的使用次數(shù)
一下是實(shí)現(xiàn)的代碼:
復(fù)制代碼 代碼如下:
<SPAN style="FONT-SIZE: 18px"><STRONG>public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
preferences = getSharedPreferences("count",MODE_WORLD_READABLE);
int count = preferences.getInt("count", 0);
//判斷程序與第幾次運(yùn)行,如果是第一次運(yùn)行則跳轉(zhuǎn)到引導(dǎo)頁(yè)面
if (count == 0) {
Intent intent = new Intent();
intent.setClass(getApplicationContext(),LaunchGuideViewActivity.class);
startActivity(intent);
this.finish();
}
Editor editor = preferences.edit();
//存入數(shù)據(jù)
editor.putInt("count", ++count);
//提交修改
editor.commit();</STRONG></SPAN>
您可能感興趣的文章:
- Android界面 NotificationManager使用Bitmap做圖標(biāo)
- Android界面設(shè)計(jì)(APP設(shè)計(jì)趨勢(shì) 左側(cè)隱藏菜單右邊顯示content)
- Android筆記之:App應(yīng)用之啟動(dòng)界面SplashActivity的使用
- android 通過(guò)向viewpage中添加listview來(lái)完成滑動(dòng)效果(類似于qq滑動(dòng)界面)
- 解析Android開發(fā)優(yōu)化之:對(duì)界面UI的優(yōu)化詳解(一)
- android 引導(dǎo)界面的實(shí)現(xiàn)方法
- android開發(fā)教程之子線程中更新界面
- Android實(shí)現(xiàn)Activity界面切換添加動(dòng)畫特效的方法
- Android中刷新界面的二種方法
- Android繪制炫酷引導(dǎo)界面
相關(guān)文章
Android自定義ViewPager實(shí)現(xiàn)個(gè)性化的圖片切換效果
這篇文章主要介紹了Android自定義ViewPager實(shí)現(xiàn)個(gè)性化的圖片切換效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-05-05
Android顯示系統(tǒng)SurfaceFlinger分析
本文詳細(xì)講解了Android顯示系統(tǒng)SurfaceFlinger,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-12-12
Flutter開發(fā)技巧RadialGradient中radius計(jì)算詳解
這篇文章主要為大家介紹了Flutter小技巧RadialGradient?中?radius?的計(jì)算詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-01-01
Android 系統(tǒng)服務(wù)TelecomService啟動(dòng)過(guò)程原理分析
這篇文章主要介紹了Android 系統(tǒng)服務(wù)TelecomService啟動(dòng)過(guò)程原理分析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-07-07
Android實(shí)現(xiàn)按鈕點(diǎn)擊事件的三種方法總結(jié)
Button是程序用于和用戶進(jìn)行交互的一個(gè)重要控件。既然有Button,那肯定有onClick方法,下面就教大家三種實(shí)現(xiàn)點(diǎn)擊事件的方法,感興趣的可以了解一下2022-04-04
解決Eclipse啟動(dòng)出錯(cuò):Failed to create the Java Virtual Machine
這篇文章主要介紹了解決Eclipse啟動(dòng)出錯(cuò):Failed to create the Java Virtual Machine的相關(guān)資料,這里說(shuō)明出錯(cuò)原因及查找錯(cuò)誤和解決辦法,需要的朋友可以參考下2017-07-07

