2024年11月17日

Compass 指南針

 Compass 指南針

特色
適用於Android的指南針、羅盤,可顯示緯度和經度,海拔,級別標籤,位置,gps速度,簡潔的界面,並且免費。指南針可幫助您找到正確的方向,包括GPS位置信息。

指南針很簡單。在外觀上很普通。它的功能對於導航非常重要。那實際上就是磁羅盤。它是指示方向的工具。如果知道北部在哪裡,就可以找到其餘的基本方向。如此簡單的工具,如果一個人無法正常工作該怎麼辦?如果您在野營旅行時迷路了怎麼辦?一個人如何找到回程?即使在不斷發展的地理空間技術時代,某些工具仍然很重要。知道如何使用指南針並運用該指南針可能會在諸如迷路的情況下有所幫助。

android google play  Compass 連結





Sudoku 數獨

 Sudoku 數獨

數獨是一款深受各年齡層玩家喜愛的流行經典數學數字遊戲!無論您是想打發時間、鍛鍊大腦還是提高數學和邏輯思維,我們的數獨益智遊戲都是您的完美選擇!

Android google play store Sudoku連結





2021年9月16日

以學生身分登入Classroom的步驟


桌機、筆電操作步驟

注意事項,
請務必先登出Chrome所有Google帳號
點擊圖片可以放大圖片顯示



1、進入員林國小網頁 (員林國小網頁連結)


2、往下滑,找到[Gsuite](紅色箭頭位置),點一下進入頁面。


3、進入後點選
[行政區]:員林市
[學校]:員林國小

4、點選輸入
[帳號]:  (學生學號)
[密碼]:  (身分證後5碼)


5、進入後點選[線上教室](紅色箭頭位置)


可能會出現帳號登錄確認


6、進入後點選[104線上教室](紅色箭頭位置)

7、進入後
點選網址進入會議或是上課
請在網址下方留下訊息、讓老師知道成功登錄,可以開會或是上課了。(例如輸入,王小明成功進入教室)








2017年12月17日

Android App Privacy Policy

隱私權政策

我們非常重視您的隱私,並致力於保護您的個人和敏感資料。本隱私權政策詳細說明我們如何收集、使用、分享和保護您的資料。使用本應用程式,即表示您同意本政策的條款。

1. 資料收集
我們可能會收集和處理以下類型的資料:
設備信息:設備類型、唯一設備標識碼、操作系統等。
位置信息:僅當應用程式需要提供基於位置的服務時,會請求訪問位置數據。
使用資料:包括應用程式的使用情況和互動記錄。

2. 適合兒童使用
本應用程式旨在成為家庭友好且適合兒童使用。為保護兒童的隱私和安全,我們遵守《兒童線上隱私保護法案》(COPPA)和其他相關的隱私法規:

我們不會在不經父母或監護人同意的情況下,向 13 歲以下兒童收集個人資料。
所有針對兒童的功能均以隱私和安全為前提設計。

3. 廣告資料收集和使用
本應用程式包含適合兒童的廣告,但我們確保廣告內容適合年齡:
設備識別碼:用於展示相關廣告。
使用數據:以了解用戶與廣告和應用程式的互動情況。
我們不會向未經授權的第三方出售或共享兒童的個人資料。廣告合作夥伴會根據法律和政策遵循適當的安全措施來保護兒童資料。

4. 資料使用
我們使用您的資料來:
提供並改善我們的服務和用戶體驗。
向您發送有關更新和應用程式的通知。
展示個性化和年齡適當的廣告內容。
確保應用程式的技術運行和安全性。

5. 資料共享
我們不會將您的個人和敏感資料出售或共享給未經授權的第三方。但我們可能會在以下情況中共享資料:
法律要求:在法律或法律程序要求時。
服務供應商:協助我們運營應用程式的可信服務供應商。
廣告合作夥伴:為了提供和優化廣告體驗,合作夥伴會遵守法律和隱私規範。

6. 第三方網站
本服務可能包含連至第三方服務或第三方其他網站之連結,這個第三方包括與您進行交易的零售商。請注意,本政策僅適用於我方透過服務收集的個人資訊,我方不對第三方可能透過其網站或服務收集、存儲及使用的個人資訊負有責任。您應始終仔細閱讀每個您瀏覽網站的隱私權政策。

7. 資料保護
我們採取適當的技術和組織措施來保護您的個人資料免遭未經授權的訪問、更改、洩露或銷毀。

8. 資料保留與刪除
我們僅在提供服務必要的期限內保留您的個人資料。在您的請求下,我們將刪除您的個人資料,除非法律要求保留。

9. 用戶權利
您有權查閱、更正或刪除您的個人資料,並有權限制或反對資料處理。如果您有此類請求,請與我們聯繫。

10. 聯絡方式
APP開發者為JackyWell所有,如有任何有關隱私權的問題或請求,請透過郵件聯繫我們
jackylee3324@gmail.com

11. 政策更新
我們可能會不時更新本隱私權政策。當我們更新時,會將新的政策發布在此頁面上,並更新政策的生效日期。

生效日期:2024/11/12

2017年12月14日

Android ToolBar

Android ToolBar

ToolBar是在安卓5.0中引入的(android.widget.Toolbar)。在不引入兼容庫的情况下,只能在5.0以上的版本運行;而在引用android.support.v7.widget.Toolbar類之後,可以支持安卓2.1以上版本。


引入了android.support.v7兼容庫。
//build.gradle
    compile 'com.android.support:appcompat-v7:25.3.0'


然後更改Application的主题,找到values文件夾下的styles.xml,更改主题為NoActionBar
<!--AndroidManifest.xml-->
<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme
        <!--修改AppTheme的定义-->
        >

<!--styles.xml-->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">



Layout布置

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/activity_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="me.zxm.learnactionbartoolbar.MainActivity"
        >
    <android.support.v7.widget.Toolbar
            android:id="@+id/ToolBar"
            android:minHeight="?attr/actionBarSize"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:titleTextColor="@android:color/white"
            android:background="?attr/colorPrimary"
            ></android.support.v7.widget.Toolbar>
</RelativeLayout>




在res文件夾下新建menu文件夾,然後在该文件夾下新增一个布局文件

<?xml version="1.0" encoding="utf-8"?>
<menu
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android">
<item
        android:id="@+id/mySearch"
        android:icon="@android:drawable/ic_menu_search"
        app:showAsAction="ifRoom"
        android:title="Search">
</item>
<item
        android:id="@+id/myMore"
        android:icon="@android:drawable/ic_menu_more"
        app:showAsAction="ifRoom|withText"
        android:title="More">
</item>
</menu>




Activity Toolbar Code

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
public class MainActivity extends AppCompatActivity implements Toolbar.OnMenuItemClickListener{
    private Toolbar toolbar;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        toolbar = (Toolbar) findViewById(R.id.ToolBar);
        toolbar.setNavigationIcon(R.mipmap.ic_launcher);
        toolbar.setLogo(R.mipmap.ic_launcher);
        toolbar.setTitle("ToolBar");

        toolbar.setSubtitle("toolbar");
        setSupportActionBar(toolbar);
        toolbar.setOnMenuItemClickListener(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu,toolbar.getMenu());
        return true;
    }
}




顯示Back圖示
toolbar = (Toolbar) findViewById(R.id.hack_toolbar);
        setSupportActionBar(toolbar);

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);

toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //do something you want
            }

        });

2017年9月24日

ViewTreeObserver

ViewTreeObserver

ViewTreeObserver vto =textViewLeft.getViewTreeObserver();vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {    @Override    public void onGlobalLayout() {        if (Build.VERSION.SDK_INT < 16) {            textViewLeft.getViewTreeObserver().removeGlobalOnLayoutListener(this);        }        else {            textViewLeft.getViewTreeObserver().removeOnGlobalLayoutListener(this);        }    }});

2017年8月1日

android E/eglCodecCommon 錯誤處理方式

android E/eglCodecCommon 錯誤處理方式

android studio 模擬器 api 22


錯誤訊息,重複出現
E/eglCodecCommon: **** ERROR unknown type 0x0 (glSizeof,73)
E/eglCodecCommon: glUtilsParamSize: unknow param 0x00000b44

處理方式
You can solve this by adding android:hardwareAccelerated="false" in AndroidManifest.xml

2017年5月8日

Android Dialog 標題換行

Android Dialog 標題換行

TextView view = new TextView(this);view.setText(appraisal.getTitle() + "\n" + appraisal.getNoticeInfo());view.setPadding(40, 20, 0, 20);view.setTextSize(12);
Dialog alertDialog = new AlertDialog.Builder(this).setCustomTitle(view);

2017年3月11日

Android 判斷手機或是平板

Android 判斷手機或是平板

public static boolean isPad(Context context) {
    return (context.getResources().getConfiguration().screenLayout
        & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
}

回傳true就是平板
回傳false就是手機

2017年2月20日

單例模式 Singleton

單例模式 Singleton

保證一個類別只有一個物件,而且要提供存取該物件的統一方法

public class FragmentOne extends Fragment {
    private static FragmentOne fragmentOne = null;

    private Singleton(){
    // 建立物件
    }

    public static FragmentOne getInstance() {
 
       if (fragmentOne == null) {
          // 多執行緒時,當物件需要被建立時才使用synchronized保證fragmentOne一定是單一的 ,增加程式校能
           synchronized(FragmentOne.class){
          if (fragmentOne == null) {
            // 第一次被呼叫的時候再建立物件
            fragmentOne = new FragmentOne();
          }
        }
        return fragmentOne;
    }

}



補充

package com.test;

public class TestSingletionPattern {

public static void main(String[] args) {
// TODO Auto-generated method stub
}

}

class Singleton {
private static final Singleton singleton = new Singleton();

private Singleton() {

}

public static Singleton getInstance() {
return singleton;
}

public static void doSomething() {

}
}

class SingletonB {
private static SingletonB singleton = new SingletonB();

private SingletonB() {

}

// 多執行緒時使用synchronized保證Singleton一定是單一的
public static synchronized SingletonB getInstance() {
if (singleton == null) {
singleton = new SingletonB();
}
return singleton;
}

public static void doSomething() {

}
}

class SingletonC {
private static SingletonC singleton = new SingletonC();

private SingletonC() {

}

// 多執行緒時,當物件需要被建立時才使用synchronized保證Singleton一定是單一的 ,增加程式校能
public static SingletonC getInstance() {
if (singleton == null) {
synchronized (SingletonC.class) {
if (singleton == null) {
singleton = new SingletonC();
}
}
}
return singleton;
}

public static void doSomething() {

}
}

2017年1月7日

Android get StatusBar Height and ActionBar Height


//取得狀態列高度
int statusBarHeight = 0;
int resource = this.getResources().getIdentifier("status_bar_height",
 "dimen", "android");
if (resource > 0) {
    statusBarHeight = this.getResources().getDimensionPixelSize(resource);
}


//取得標題列高度
int actionBarHeight=0;
TypedValue tv = new TypedValue();
if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
{
    actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,
getResources().getDisplayMetrics());
}

//應用區域高度
Rect outRect1 = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect1);

//VIEW繪製區域高度
Rect outRect2 = new Rect();
getWindow().findViewById(Window.ID_ANDROID_CONTENT).getDrawingRect(outRect2);

2016年12月19日

關於條碼掃描Zxing,需要掃描時直立顯示:

關於條碼掃描Zxing,需要掃描時直立顯示:

android提供的SDK(android.hardware.Camera)裡大概不能正常的使用直立顯示(portrait layout)加載照相機,當用直立顯示模式加載照相機時會產生以下情況:

1.照相機成像左傾90度(傾斜);
2.照相機成像長寬比例不對(失比)。



基本上解決辦法如下:

1、在AndroidManifest.xml裡面配置一下 ,使CaptureActivity属性為portrait:android:screenOrientation="portrait"

2、如果只是單純的想改變照相機成像的方向,只需要在com.google.zxing.client.android.camera下的   CameraConfigurationManager類別中增加方法  

protected void setDisplayOrientation(Camera camera, int angle) {
        Method downPolymorphic;
   try {        
    downPolymorphic = camera.getClass().getMethod("setDisplayOrientation", new Class[] { int.class });
           if (downPolymorphic != null)
    downPolymorphic.invoke(camera, new Object[] { angle });
  } catch (Exception e1) {         }
}

然後在方法void setDesiredCameraParameters(Camera camera){}中調用, setDisplayOrientation(camera, 90);     具體位置在camera.setParameters(parameters);語句前面。

3、改變完方向你會發現方向改變可可分辨率會變得很低,接下來就是優化了

1)首先在類別CameraManager.java中把
rect.left = rect.left * cameraResolution.x / screenResolution.x;
rect.right = rect.right * cameraResolution.x / screenResolution.x;
rect.top = rect.top * cameraResolution.y / screenResolution.y;
rect.bottom = rect.bottom * cameraResolution.y / screenResolution.y;

替換成
rect.left = rect.left * cameraResolution.y / screenResolution.x;
rect.right = rect.right * cameraResolution.y / screenResolution.x;
rect.top = rect.top * cameraResolution.x / screenResolution.y;
rect.bottom = rect.bottom * cameraResolution.x / screenResolution.y;

(2)然後是在DecodeHandler類別中的方法private void decode(byte[] data,int width,int height){}中添加

byte[] rotatedData = new byte[data.length];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++)
rotatedData[x * height + height - y - 1] = data[x + y * width];

(3)再就是CameraConfigurationManager類別中的方法void initFromCameraParameters(Camera camera){}中添加如下代碼:

Point screenResolutionForCamera = new Point();
screenResolutionForCamera.x = screenResolution.x;
screenResolutionForCamera.y = screenResolution.y;

// preview size is always something like 480*320, other 320*480
if (screenResolution.x < screenResolution.y) {
   screenResolutionForCamera.x = screenResolution.y;
  screenResolutionForCamera.y = screenResolution.x;

2016年12月10日

JackyAndJustin Android App 隱私權政策

JackyAndJustin Android App Privacy Policy


Information that may be collected from you
When you use this app, you do not need to enter your personal information (such as your name, ID number, email address, etc.). You will not acquire your personal information without your knowledge, unless you know in advance.

Third-party website
This service may include links to third party services or other third party websites that include the retailer with whom you deal. Please note that this policy applies only to personal information we collect through our services and we are not responsible for the personal information that third parties may collect, store and use through their websites or services. You should always read through the privacy policies of every web site you visit.


This policy change
We may from time to time make changes to this policy for a variety of reasons, for example, to reflect changes in laws and regulations or changes in industry specifications and technology.

If you have any questions or comments about this policy, please contact us.


隱私權政策

可能向您收集之資訊
您使用此APP時,並不需要輸入個人資料 (例如姓名、身分證字號、電子郵件地址等 ) ,除非事先告知,此APP不會在您不知情的狀況下,取得您個人資料。

第三方網站
本服務可能包含連至第三方服務或第三方其他網站之連結,這個第三方包括與您進行交易的零售商。請注意,本政策僅適用於我方透過服務收集的個人資訊,我方不對第三方可能透過其網站或服務收集、存儲及使用的個人資訊負有責任。您應始終仔細閱讀每個您瀏覽網站的隱私權政策。


本政策的變更
我方可能因各種原因而需不時對本政策進行變更,例如,為了反應法律與法規的變更或行業規範與技術發展的改變。

如果您對本政策有任何問題或意見,請聯絡我們。

2016年12月8日

Android 使用Snackbar跟CoordinatorLayout

Android 使用Snackbar跟CoordinatorLayout


build.gradle

dependencies {
    compile 'com.android.support:design:24.2.1'
}



activity_main.xml布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">
    <Button
        android:onClick="createSnackbar"
        android:text="@string/snackbar_test_button_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"/>
</RelativeLayout>



MainActivity

container = (CoordinatorLayout) findViewById(R.id.container);

Snackbar.make(container, "This is explanation: Please give us permission", Snackbar.LENGTH_LONG)
                            .setAction("OK", new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    requestExternalStoragePermission();
                                }
                            }).show();

2016年11月25日

Android 禁止螢幕旋轉

Android 禁止螢幕旋轉


AndroidManifest.xml設置
android:screenOrientation="portrait"  (強制直向)
android:screenOrientation="landscape"  (強制橫向)


Java Code設置
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//畫面直向
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);//畫面橫向


以上畫面只要轉方向時,activity 會重新執行。



1、如果不要 activity 重新執行,需要在 AndroidManifest.xml 檔案中,在 activity 加入 android:configChanges="orientation|keyboardHidden" 就會禁止重新執行。

這個屬性指的是,當後邊屬性值代表的事件發生時,Activity 會執行某個函數,orientation 指的是當螢幕旋轉時,keyboardHidden 指的是鍵盤輔助功能改變。“|”為或符號,指這兩個中任意一個發生,就執行 Activity 某個函數。
如果你的開發 API 等級等於或高於 13,你還需要設置 screenSize,因為 screenSize 會在螢幕旋轉時改變。


2、在對應 Activity 中重寫 onConfigurationChanged() 方法:
@Override
public void onConfigurationChanged(Configuration newConfig) {
    // TODO Auto-generated method stub
    super.onConfigurationChanged(newConfig);
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        // 什麼都不用寫
    }
    else {
        // 什麼都不用寫
    }
}

如果在 if、else 中,使用了 setContentView(R.layout.xxxx) 函數,那麼就可以實現:每次螢幕旋轉時,調用不同的佈局。


3、動態更改螢幕方向:

在程式中有需要的時候旋轉螢幕,例如
@Override
public void onClick(View v) {
    // 如果是豎排,則改為橫向
    if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
    // 如果是橫排,則改為直向
    else if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
}
重點就是:getRequestedOrientation() 函數、setRequestedOrientation() 函數的使用。
注意:使用這種方法,必須事先在 AndroidManifest.xml 的 <activity> </activity> 中,添加android:screenOrientation 屬性值,不然 getRequestedOrientation() 可能會出問題。

2016年11月23日

Android Intent用法

Android Intent用法

顯示網頁
Uri uri = Uri.parse("http://google.com");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);


使用郵件MAIL
//傳送文字
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, "emailaddress@emailaddress.com");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT, "I'm email body.");
startActivity(Intent.createChooser(intent, "Send Email"));

//傳送影音附件檔
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
it.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/mysong.mp3"));
it.setType("audio/mp3");
startActivity(Intent.createChooser(it, "Choose Email Client"));

//傳送圖片附件檔
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
it.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/mypic.jpg"));
it.setType("image/jpeg");
startActivity(Intent.createChooser(it, "Choose Email Client"));


撥打電話
//叫出撥號程式
Uri uri = Uri.parse("tel:0800000123");
Intent it = new Intent(Intent.ACTION_DIAL, uri);
startActivity(it);
//直接打電話出去
Uri uri = Uri.parse("tel:0800000123");
Intent it = new Intent(Intent.ACTION_CALL, uri);
startActivity(it);
//用這個,要在 AndroidManifest.xml 中,加上
//<uses-permission id="android.permission.CALL_PHONE" />



顯示聯絡人清單
Intent it = new Intent(Intent.ACTION_VIEW, People.CONTENT_URI);
startActivity(it);



播放多媒體
Intent it = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("file:///sdcard/song.mp3");
it.setDataAndType(uri, "audio/mp3");
startActivity(it);
Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);


安裝 APK 檔
Uri uri = Uri.parse("url_of_apk_file");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
it.setData(uri);
it.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
it.setClassName("com.android.packageinstaller",
                "com.android.packageinstaller.PackageInstallerActivity");
startActivity(it);
//make sure the url_of_apk_file is readable for all users

2016年11月19日

Android 常用系統預設文字大小以及顏色

Android 常用系統預設文字大小以及顏色


<TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />


android:textAppearance="?android:attr/textAppearanceLarge"  或是
sytle="?android:attr/textAppearanceLarge" 實際上是一樣的。


文字大小
android:textAppearance="?android:attr/textAppearanceLarge"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textAppearance="?android:attr/textAppearanceSmall"

字體顏色
android:textColor="?android:attr/textColorPrimary"
android:textColor="?android:attr/textColorSecondary"
android:textColor="?android:attr/textColorTertiary"
android:textColor="?android:attr/textColorPrimaryInverse"
android:textColor="?android:attr/textColorSecondaryInverse"

2016年11月14日

Android studio測試問題 測試會出現安裝兩個相同APP

Android studio測試問題 測試會出現安裝兩個相同APP

問題出現在AndroidManifest.xml寫入2個Activity<intent-filter>
只要刪除底下紅色字體代碼即可以修正錯誤,正常測試。
AndroidManifest.xml


<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:theme="@style/AppTheme.NoActionBar">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

<activity
    android:name=".SetupActivityListSample"
    android:label="@string/app_name"
    android:theme="@style/AppTheme.NoActionBar">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

2016年11月7日

Android AlertDialog

Android AlertDialog

建立AlertDialog對話盒

AlertDialog.Builder builder  = new AlertDialog.Builder(gameViewA.getContext());
builder.setTitle("抬頭訊息...");
builder.setMessage("本文訊息");

builder.setNegativeButton("右邊按鈕", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
  }
});
builder.setNeutralButton("中間按鈕", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
  }
});
 builder.setPositiveButton("左邊按鈕", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
  }
});
 AlertDialog alert = builder.create();
 alert.show();

2016年11月6日

Android SensorManager Accuracy Value

Android SensorManager Accuracy Value


public void onAccuracyChanged(Sensor sensor, int accuracy) {
     }


int accuracy


int SENSOR_STATUS_ACCURACY_HIGH
This sensor is reporting data with maximum accuracy

Constant Value: 3 (0x00000003)


int SENSOR_STATUS_ACCURACY_LOW
This sensor is reporting data with low accuracy, calibration with the environment is needed

Constant Value: 1 (0x00000001)


int SENSOR_STATUS_ACCURACY_MEDIUM
This sensor is reporting data with an average level of accuracy, calibration with the environment may improve the readings

Constant Value: 2 (0x00000002)

int SENSOR_STATUS_NO_CONTACT
The values returned by this sensor cannot be trusted because the sensor had no contact with what it was measuring (for example, the heart rate monitor is not in contact with the user).

Constant Value: -1 (0xffffffff)


int SENSOR_STATUS_UNRELIABLE
The values returned by this sensor cannot be trusted, calibration is needed or the environment doesn't allow readings

Constant Value: 0 (0x00000000)