第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

平板電腦或手機-android

平板電腦或手機-android

胡子哥哥 2019-07-02 16:46:59
平板電腦或手機-android有沒有一種方法來檢查用戶使用的是平板電腦還是手機?我的傾斜功能和我的新平板電腦(變壓器)有問題
查看完整描述

3 回答

?
吃雞游戲

TA貢獻1829條經(jīng)驗 獲得超7個贊

這篇文章幫了我很大的忙,

不幸的是,我沒有必要的聲譽來評估所有幫助我的答案。

我需要識別我的設(shè)備是平板電腦還是手機,這樣我就能夠?qū)崿F(xiàn)屏幕的邏輯。在我的分析中,從MDPI開始,平板電腦必須超過7英寸(XLarge)。

下面的代碼是基于這篇文章創(chuàng)建的。

/**
 * Checks if the device is a tablet or a phone
 * 
 * @param activityContext
 *            The Activity Context.
 * @return Returns true if the device is a Tablet
 */public static boolean isTabletDevice(Context activityContext) {
    // Verifies if the Generalized Size of the device is XLARGE to be
    // considered a Tablet
    boolean xlarge = ((activityContext.getResources().getConfiguration().screenLayout & 
                        Configuration.SCREENLAYOUT_SIZE_MASK) == 
                        Configuration.SCREENLAYOUT_SIZE_XLARGE);

    // If XLarge, checks if the Generalized Density is at least MDPI
    // (160dpi)
    if (xlarge) {
        DisplayMetrics metrics = new DisplayMetrics();
        Activity activity = (Activity) activityContext;
        activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);

        // MDPI=160, DEFAULT=160, DENSITY_HIGH=240, DENSITY_MEDIUM=160,
        // DENSITY_TV=213, DENSITY_XHIGH=320
        if (metrics.densityDpi == DisplayMetrics.DENSITY_DEFAULT                
        || metrics.densityDpi == DisplayMetrics.DENSITY_HIGH                
        || metrics.densityDpi == DisplayMetrics.DENSITY_MEDIUM                
        || metrics.densityDpi == DisplayMetrics.DENSITY_TV                
        || metrics.densityDpi == DisplayMetrics.DENSITY_XHIGH) {

            // Yes, this is a tablet!
            return true;
        }
    }

    // No, this is not a tablet!
    return false;}


查看完整回答
反對 回復(fù) 2019-07-02
  • 3 回答
  • 0 關(guān)注
  • 430 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號