Example usage for android.os Build PRODUCT

List of usage examples for android.os Build PRODUCT

Introduction

In this page you can find the example usage for android.os Build PRODUCT.

Prototype

String PRODUCT

To view the source code for android.os Build PRODUCT.

Click Source Link

Document

The name of the overall product.

Usage

From source file:org.cocos2dx.lib.Cocos2dxActivity.java

private final static boolean isAndroidEmulator() {
    String model = Build.MODEL;//from   w ww.  j a va  2 s  .  co m
    Log.d(TAG, "model=" + model);
    String product = Build.PRODUCT;
    Log.d(TAG, "product=" + product);
    boolean isEmulator = false;
    if (product != null) {
        isEmulator = product.equals("sdk") || product.contains("_sdk") || product.contains("sdk_");
    }
    Log.d(TAG, "isEmulator=" + isEmulator);
    return isEmulator;
}

From source file:com.framgia.android.emulator.EmulatorDetector.java

private boolean checkBasic() {
    boolean result = Build.FINGERPRINT.startsWith("generic") || Build.MODEL.contains("google_sdk")
            || Build.MODEL.toLowerCase().contains("droid4x") || Build.MODEL.contains("Emulator")
            || Build.MODEL.contains("Android SDK built for x86") || Build.MANUFACTURER.contains("Genymotion")
            || Build.HARDWARE.equals("goldfish") || Build.HARDWARE.equals("vbox86")
            || Build.PRODUCT.equals("sdk") || Build.PRODUCT.equals("google_sdk")
            || Build.PRODUCT.equals("sdk_x86") || Build.PRODUCT.equals("vbox86p")
            || Build.BOARD.toLowerCase().contains("nox") || Build.BOOTLOADER.toLowerCase().contains("nox")
            || Build.HARDWARE.toLowerCase().contains("nox") || Build.PRODUCT.toLowerCase().contains("nox")
            || Build.SERIAL.toLowerCase().contains("nox");

    if (result)//from  w  w w  . ja  v  a2s. c o m
        return true;
    result |= Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic");
    if (result)
        return true;
    result |= "google_sdk".equals(Build.PRODUCT);
    return result;
}

From source file:com.architjn.materialicons.ui.fragments.HomeFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == android.R.id.home) {
        drawer.openDrawer(Gravity.LEFT);
    }//from w  w w .  j a  va 2  s. c o m
    if (id == R.id.action_sendemail) {
        StringBuilder emailBuilder = new StringBuilder();

        Intent intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("mailto:" + getResources().getString(R.string.email_id)));
        intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject));

        emailBuilder.append("\n \n \nOS Version: ").append(System.getProperty("os.version")).append("(")
                .append(Build.VERSION.INCREMENTAL).append(")");
        emailBuilder.append("\nOS API Level: ").append(Build.VERSION.SDK_INT);
        emailBuilder.append("\nDevice: ").append(Build.DEVICE);
        emailBuilder.append("\nManufacturer: ").append(Build.MANUFACTURER);
        emailBuilder.append("\nModel (and Product): ").append(Build.MODEL).append(" (").append(Build.PRODUCT)
                .append(")");
        PackageInfo appInfo = null;
        try {
            appInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        assert appInfo != null;
        emailBuilder.append("\nApp Version Name: ").append(appInfo.versionName);
        emailBuilder.append("\nApp Version Code: ").append(appInfo.versionCode);

        intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString());
        startActivity(Intent.createChooser(intent, (getResources().getString(R.string.send_title))));
        return true;
    } else if (id == R.id.action_share) {
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        String shareBody = getResources().getString(R.string.share_one)
                + getResources().getString(R.string.developer_name)
                + getResources().getString(R.string.share_two) + MARKET_URL + getActivity().getPackageName();
        sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
        startActivity(Intent.createChooser(sharingIntent, (getResources().getString(R.string.share_title))));
    } else if (id == R.id.action_changelog) {
        showChangelog();
    }

    return super.onOptionsItemSelected(item);
}

From source file:net.frakbot.FWeather.util.FeedbackService.java

/**
 * Builds a feedback email body with some basic system info.
 *
 * @return Returns the generated system info.
 */// w  ww  .j  a v  a  2 s .  co  m
@SuppressWarnings("StringBufferReplaceableByString")
private String generateFeedbackBody() {
    StringBuilder sb = new StringBuilder("\n\n" + "-----------\n" + "System info\n" + "-----------\n\n");

    // HW information
    sb.append("Device model: ").append(Build.MODEL).append("\n");
    sb.append("Manifacturer: ").append(Build.MANUFACTURER).append("\n");
    sb.append("Brand: ").append(Build.BRAND).append("\n");
    sb.append("CPU ABI: ").append(Build.CPU_ABI).append("\n");
    sb.append("Product: ").append(Build.PRODUCT).append("\n").append("\n");

    // SW information
    sb.append("Android version: ").append(Build.VERSION.CODENAME).append("\n");
    sb.append("Release: ").append(Build.VERSION.RELEASE).append("\n");
    sb.append("Incremental: ").append(Build.VERSION.INCREMENTAL).append("\n");
    sb.append("Build: ").append(Build.FINGERPRINT).append("\n");
    sb.append("Kernel: ").append(getKernelVersion()).append("\n");

    // App info
    sb.append("App version: ").append(getAppVersionNumber(this));

    return sb.toString();
}

From source file:edu.tjhsst.ion.gcmFrame.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.setContentView(R.layout.activity_main);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(getResources().getColor(R.color.navbar_color));

    }/*w w  w . ja v  a  2 s  . c o m*/
    // requestWindowFeature(Window.FEATURE_NO_TITLE);

    mRegistrationBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
            boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false);
            if (sentToken) {
                Log.i(TAG, "Google token sent");

            } else {
                Toast.makeText(getApplicationContext(), getString(R.string.token_error_message),
                        Toast.LENGTH_LONG).show();
            }
        }

    };

    if (checkPlayServices()) {
        // Start IntentService to register this application with GCM.
        Intent intent = new Intent(this, RegistrationIntentService.class);
        startService(intent);
    }

    ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(
            Context.CONNECTIVITY_SERVICE);
    if (connectivityManager != null) {
        NetworkInfo ni = connectivityManager.getActiveNetworkInfo();
        if (ni != null) {
            NetworkInfo.State state = ni.getState();
            if (state == null || state != NetworkInfo.State.CONNECTED) {
                // record the fact that there is no connection
                isConnected = false;
            }
        }
    }

    SharedPreferences sharedPreferences = PreferenceManager
            .getDefaultSharedPreferences(getApplicationContext());
    boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.ION_SETUP, false);

    webView = (WebView) findViewById(R.id.webview);

    webView.setInitialScale(1);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setLoadWithOverviewMode(true);

    webView.getSettings().setUseWideViewPort(true);
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    webView.setScrollbarFadingEnabled(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }
    StringBuilder uaString = new StringBuilder(webView.getSettings().getUserAgentString());
    uaString.append(" - IonAndroid: gcmFrame (");
    if (sentToken) {
        uaString.append("appRegistered:True");
    } else {
        uaString.append("appRegistered:False");
    }
    uaString.append(" osVersion:").append(System.getProperty("os.version"));
    uaString.append(" apiLevel:").append(android.os.Build.VERSION.SDK_INT);
    uaString.append(" Device:").append(android.os.Build.DEVICE);
    uaString.append(" Model:").append(android.os.Build.MODEL);
    uaString.append(" Product:").append(android.os.Build.PRODUCT);
    uaString.append(")");
    webView.getSettings().setUserAgentString(uaString.toString());

    webView.setNetworkAvailable(isConnected);

    webView.addJavascriptInterface(new WebAppInterface(this), "IonAndroidInterface");

    webView.loadUrl(MainActivity.ION_HOST);

    webView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            Log.d(TAG, "Loading " + url);
            if (!isConnected) {
                String html = getHtml("offline.html");
                html = html.replaceAll("\\[url\\]", url);
                view.loadData(html, "text/html", "utf-8");
                return true;
            } else if (url.contains(ION_HOST)) {
                // keep in WebView
                webView.loadUrl(url);
                return true;
            } else {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(url));
                startActivity(intent);
                return true;
            }
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            // if (errorCode == ERROR_TIMEOUT)
            view.stopLoading(); // may not be needed
            String html = getHtml("timeout.html");
            html = html.replaceAll("\\[url\\]", failingUrl);
            html = html.replaceAll("\\[desc\\]", description);
            view.loadData(html, "text/html", "utf-8");
        }
    });

}

From source file:com.aniruddhc.acemusic.player.LauncherActivity.LauncherActivity.java

@SuppressLint("NewApi")
@Override//w  w w  .  jav  a2s. c o m
public void onCreate(Bundle savedInstanceState) {

    setTheme(R.style.AppThemeNoActionBar);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_launcher);

    mContext = this;
    mActivity = this;
    mApp = (Common) mContext.getApplicationContext();
    mHandler = new Handler();

    //Increment the start count. This value will be used to determine when the library should be rescanned.
    int startCount = mApp.getSharedPreferences().getInt("START_COUNT", 1);
    mApp.getSharedPreferences().edit().putInt("START_COUNT", startCount + 1).commit();

    //Save the dimensions of the layout for later use on KitKat devices.
    final RelativeLayout launcherRootView = (RelativeLayout) findViewById(R.id.launcher_root_view);
    launcherRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {

            try {

                int screenDimens[] = new int[2];
                int screenHeight = 0;
                int screenWidth = 0;
                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
                    //API levels 14, 15 and 16.
                    screenDimens = getTrueDeviceResolution();
                    screenWidth = screenDimens[0];
                    screenHeight = screenDimens[1];

                } else {
                    //API levels 17+.
                    Display display = getWindowManager().getDefaultDisplay();
                    DisplayMetrics metrics = new DisplayMetrics();
                    display.getRealMetrics(metrics);
                    screenHeight = metrics.heightPixels;
                    screenWidth = metrics.widthPixels;

                }

                int layoutHeight = launcherRootView.getHeight();
                int layoutWidth = launcherRootView.getWidth();

                int extraHeight = screenHeight - layoutHeight;
                int extraWidth = screenWidth = layoutWidth;

                mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT", layoutHeight).commit();
                mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH", layoutWidth).commit();
                mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT_LAND", layoutWidth - extraHeight)
                        .commit();
                mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH_LAND", screenHeight).commit();

            } catch (Exception e) {
                e.printStackTrace();
            }

        }

    });

    //Build the music library based on the user's scan frequency preferences.
    int scanFrequency = mApp.getSharedPreferences().getInt("SCAN_FREQUENCY", 5);
    int updatedStartCount = mApp.getSharedPreferences().getInt("START_COUNT", 1);

    //Launch the appropriate activity based on the "FIRST RUN" flag.
    if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true) {

        //Create the default Playlists directory if it doesn't exist.
        File playlistsDirectory = new File(Environment.getExternalStorageDirectory() + "/Playlists/");
        if (!playlistsDirectory.exists() || !playlistsDirectory.isDirectory()) {
            playlistsDirectory.mkdir();
        }

        //Disable equalizer for HTC devices by default.
        if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true
                && Build.PRODUCT.contains("HTC")) {
            mApp.getSharedPreferences().edit().putBoolean("EQUALIZER_ENABLED", false).commit();
        }

        //Send out a test broadcast to initialize the homescreen/lockscreen widgets.
        sendBroadcast(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME));

        Intent intent = new Intent(this, WelcomeActivity.class);
        startActivity(intent);
        overridePendingTransition(R.anim.fade_in, R.anim.fade_out);

    } else if (mApp.isBuildingLibrary()) {
        buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text);
        buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info);
        buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout);

        buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryInfoText.setPaintFlags(
                buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryMainText.setPaintFlags(
                buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        buildingLibraryMainText.setText(R.string.jams_is_building_library);
        buildingLibraryLayout.setVisibility(View.VISIBLE);

        //Initialize the runnable that will fire once the scan process is complete.
        mHandler.post(scanFinishedCheckerRunnable);

    } else if (mApp.getSharedPreferences().getBoolean("RESCAN_ALBUM_ART", false) == true) {

        buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text);
        buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info);
        buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout);

        buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryInfoText.setPaintFlags(
                buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryMainText.setPaintFlags(
                buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        buildingLibraryMainText.setText(R.string.jams_is_caching_artwork);
        initScanProcess(0);

    } else if ((mApp.getSharedPreferences().getBoolean("REBUILD_LIBRARY", false) == true)
            || (scanFrequency == 0 && mApp.isScanFinished() == false)
            || (scanFrequency == 1 && mApp.isScanFinished() == false && updatedStartCount % 3 == 0)
            || (scanFrequency == 2 && mApp.isScanFinished() == false && updatedStartCount % 5 == 0)
            || (scanFrequency == 3 && mApp.isScanFinished() == false && updatedStartCount % 10 == 0)
            || (scanFrequency == 4 && mApp.isScanFinished() == false && updatedStartCount % 20 == 0)) {

        buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text);
        buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info);
        buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout);

        buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryInfoText.setPaintFlags(
                buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryMainText.setPaintFlags(
                buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        initScanProcess(1);

    } else {

        //Check if this activity was called from Settings.
        if (getIntent().hasExtra("UPGRADE")) {
            if (getIntent().getExtras().getBoolean("UPGRADE") == true) {
                mExplicitShowTrialFragment = true;
            } else {
                mExplicitShowTrialFragment = false;
            }

        }

        //initInAppBilling();
        launchMainActivity();
    }

    //Fire away a report to Google Analytics.
    try {
        if (mApp.isGoogleAnalyticsEnabled() == true) {
            EasyTracker easyTracker = EasyTracker.getInstance(this);
            easyTracker.send(MapBuilder.createEvent("ACE startup.", // Event category (required)
                    "User started ACE.", // Event action (required)
                    "User started ACE.", // Event label
                    null) // Event value
                    .build());
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.cc.signalinfo.fragments.SignalFragment.java

/**
 * Set the phone model, OS version, carrier name on the screen
 *//*from w  w w  .jav a  2 s . com*/
private void setPhoneInfo() {
    setTextViewText(R.id.deviceName, String.format("%s %s", Build.MANUFACTURER, Build.MODEL));
    setTextViewText(R.id.deviceModel, String.format("%s/%s (%s) ", Build.PRODUCT, Build.DEVICE, Build.ID));
    setTextViewText(R.id.androidVersion, String.format(activity.getString(R.string.androidVersion),
            Build.VERSION.RELEASE, Build.VERSION.SDK_INT));

    setTextViewText(R.id.carrierName, tm.getNetworkOperatorName());
    setTextViewText(R.id.buildHost, Build.HOST);
    setNetworkTypeText();
}

From source file:com.Duo.music.player.LauncherActivity.LauncherActivity.java

@SuppressLint("NewApi")
@Override//from ww  w  .  ja  va  2  s  . c o m
public void onCreate(Bundle savedInstanceState) {

    setTheme(R.style.AppThemeNoActionBar);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_launcher);

    mContext = this;
    mActivity = this;
    mApp = (Common) mContext.getApplicationContext();
    mHandler = new Handler();

    //Increment the start count. This value will be used to determine when the library should be rescanned.
    int startCount = mApp.getSharedPreferences().getInt("START_COUNT", 1);
    mApp.getSharedPreferences().edit().putInt("START_COUNT", startCount + 1).commit();

    //Save the dimensions of the layout for later use on KitKat devices.
    final RelativeLayout launcherRootView = (RelativeLayout) findViewById(R.id.launcher_root_view);
    launcherRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {

            try {

                int screenDimens[] = new int[2];
                int screenHeight = 0;
                int screenWidth = 0;
                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
                    //API levels 14, 15 and 16.
                    screenDimens = getTrueDeviceResolution();
                    screenWidth = screenDimens[0];
                    screenHeight = screenDimens[1];

                } else {
                    //API levels 17+.
                    Display display = getWindowManager().getDefaultDisplay();
                    DisplayMetrics metrics = new DisplayMetrics();
                    display.getRealMetrics(metrics);
                    screenHeight = metrics.heightPixels;
                    screenWidth = metrics.widthPixels;

                }

                int layoutHeight = launcherRootView.getHeight();
                int layoutWidth = launcherRootView.getWidth();

                int extraHeight = screenHeight - layoutHeight;
                int extraWidth = screenWidth = layoutWidth;

                mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT", layoutHeight).commit();
                mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH", layoutWidth).commit();
                mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT_LAND", layoutWidth - extraHeight)
                        .commit();
                mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH_LAND", screenHeight).commit();

            } catch (Exception e) {
                e.printStackTrace();
            }

        }

    });

    //Build the music library based on the user's scan frequency preferences.
    int scanFrequency = mApp.getSharedPreferences().getInt("SCAN_FREQUENCY", 5);
    int updatedStartCount = mApp.getSharedPreferences().getInt("START_COUNT", 1);

    //Launch the appropriate activity based on the "FIRST RUN" flag.
    if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true) {

        //Create the default Playlists directory if it doesn't exist.
        File playlistsDirectory = new File(Environment.getExternalStorageDirectory() + "/Playlists/");
        if (!playlistsDirectory.exists() || !playlistsDirectory.isDirectory()) {
            playlistsDirectory.mkdir();
        }

        //Disable equalizer for HTC devices by default.
        if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true
                && Build.PRODUCT.contains("HTC")) {
            mApp.getSharedPreferences().edit().putBoolean("EQUALIZER_ENABLED", false).commit();
        }

        //Send out a test broadcast to initialize the homescreen/lockscreen widgets.
        sendBroadcast(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME));

        Intent intent = new Intent(this, WelcomeActivity.class);
        startActivity(intent);
        overridePendingTransition(R.anim.fade_in, R.anim.fade_out);

    } else if (mApp.isBuildingLibrary()) {
        buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text);
        buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info);
        buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout);

        buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryInfoText.setPaintFlags(
                buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryMainText.setPaintFlags(
                buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        buildingLibraryMainText.setText(R.string.jams_is_building_library);
        buildingLibraryLayout.setVisibility(View.VISIBLE);

        //Initialize the runnable that will fire once the scan process is complete.
        mHandler.post(scanFinishedCheckerRunnable);

    } else if (mApp.getSharedPreferences().getBoolean("RESCAN_ALBUM_ART", false) == true) {

        buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text);
        buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info);
        buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout);

        buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryInfoText.setPaintFlags(
                buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryMainText.setPaintFlags(
                buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        buildingLibraryMainText.setText(R.string.jams_is_caching_artwork);
        initScanProcess(0);

    } else if ((mApp.getSharedPreferences().getBoolean("REBUILD_LIBRARY", false) == true)
            || (scanFrequency == 0 && mApp.isScanFinished() == false)
            || (scanFrequency == 1 && mApp.isScanFinished() == false && updatedStartCount % 3 == 0)
            || (scanFrequency == 2 && mApp.isScanFinished() == false && updatedStartCount % 5 == 0)
            || (scanFrequency == 3 && mApp.isScanFinished() == false && updatedStartCount % 10 == 0)
            || (scanFrequency == 4 && mApp.isScanFinished() == false && updatedStartCount % 20 == 0)) {

        buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text);
        buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info);
        buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout);

        buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryInfoText.setPaintFlags(
                buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryMainText.setPaintFlags(
                buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        initScanProcess(1);

    } else {

        //Check if this activity was called from Settings.
        if (getIntent().hasExtra("UPGRADE")) {
            if (getIntent().getExtras().getBoolean("UPGRADE") == true) {
                mExplicitShowTrialFragment = true;
            } else {
                mExplicitShowTrialFragment = false;
            }

        }

        //initInAppBilling();
        launchMainActivity();
    }

    //Fire away a report to Google Analytics.
    try {
        if (mApp.isGoogleAnalyticsEnabled() == true) {
            EasyTracker easyTracker = EasyTracker.getInstance(this);
            easyTracker.send(MapBuilder.createEvent("Jams startup.", // Event category (required)
                    "User started Jams.", // Event action (required)
                    "User started Jams.", // Event label
                    null) // Event value
                    .build());
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.jams.music.player.LauncherActivity.LauncherActivity.java

@SuppressLint("NewApi")
@Override/*w  w w .  j av  a 2  s  .  c  o m*/
public void onCreate(Bundle savedInstanceState) {

    setTheme(R.style.AppThemeNoActionBar);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_launcher);

    mContext = this;
    mActivity = this;
    mApp = (Common) mContext.getApplicationContext();
    mHandler = new Handler();

    //Increment the start count. This value will be used to determine when the library should be rescanned.
    int startCount = mApp.getSharedPreferences().getInt("START_COUNT", 1);
    mApp.getSharedPreferences().edit().putInt("START_COUNT", startCount + 1).commit();

    //Save the dimensions of the layout for later use on KitKat devices.
    final RelativeLayout launcherRootView = (RelativeLayout) findViewById(R.id.launcher_root_view);
    launcherRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {

            try {

                int screenDimens[] = new int[2];
                int screenHeight = 0;
                int screenWidth = 0;
                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
                    //API levels 14, 15 and 16.
                    screenDimens = getTrueDeviceResolution();
                    screenWidth = screenDimens[0];
                    screenHeight = screenDimens[1];

                } else {
                    //API levels 17+.
                    Display display = getWindowManager().getDefaultDisplay();
                    DisplayMetrics metrics = new DisplayMetrics();
                    display.getRealMetrics(metrics);
                    screenHeight = metrics.heightPixels;
                    screenWidth = metrics.widthPixels;

                }

                int layoutHeight = launcherRootView.getHeight();
                int layoutWidth = launcherRootView.getWidth();

                int extraHeight = screenHeight - layoutHeight;
                int extraWidth = screenWidth = layoutWidth;

                mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT", layoutHeight).commit();
                mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH", layoutWidth).commit();
                mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT_LAND", layoutWidth - extraHeight)
                        .commit();
                mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH_LAND", screenHeight).commit();

            } catch (Exception e) {
                e.printStackTrace();
            }

        }

    });

    //Build the music library based on the user's scan frequency preferences.
    int scanFrequency = mApp.getSharedPreferences().getInt("SCAN_FREQUENCY", 5);
    int updatedStartCount = mApp.getSharedPreferences().getInt("START_COUNT", 1);

    //Launch the appropriate activity based on the "FIRST RUN" flag.
    if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true) {

        //Create the default Playlists directory if it doesn't exist.
        File playlistsDirectory = new File(Environment.getExternalStorageDirectory() + "/Playlists/");
        if (!playlistsDirectory.exists() || !playlistsDirectory.isDirectory()) {
            playlistsDirectory.mkdir();
        }

        //Disable equalizer for HTC devices by default.
        if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true
                && Build.PRODUCT.contains("HTC")) {
            mApp.getSharedPreferences().edit().putBoolean("EQUALIZER_ENABLED", false).commit();
        }

        //Send out a test broadcast to initialize the homescreen/lockscreen widgets.
        sendBroadcast(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME));

        Intent intent = new Intent(this, WelcomeActivity.class);
        startActivity(intent);
        overridePendingTransition(R.anim.fade_in, R.anim.fade_out);

    } else if (mApp.isBuildingLibrary()) {
        buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text);
        buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info);
        buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout);

        buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryInfoText.setPaintFlags(
                buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryMainText.setPaintFlags(
                buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        buildingLibraryMainText.setText(R.string.jams_is_building_library);
        buildingLibraryLayout.setVisibility(View.VISIBLE);

        //Initialize the runnable that will fire once the scan process is complete.
        mHandler.post(scanFinishedCheckerRunnable);

    } else if (mApp.getSharedPreferences().getBoolean("RESCAN_ALBUM_ART", false) == true) {

        buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text);
        buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info);
        buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout);

        buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryInfoText.setPaintFlags(
                buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryMainText.setPaintFlags(
                buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        buildingLibraryMainText.setText(R.string.jams_is_caching_artwork);
        initScanProcess(0);

    } else if ((mApp.getSharedPreferences().getBoolean("REBUILD_LIBRARY", false) == true)
            || (scanFrequency == 0 && mApp.isScanFinished() == false)
            || (scanFrequency == 1 && mApp.isScanFinished() == false && updatedStartCount % 3 == 0)
            || (scanFrequency == 2 && mApp.isScanFinished() == false && updatedStartCount % 5 == 0)
            || (scanFrequency == 3 && mApp.isScanFinished() == false && updatedStartCount % 10 == 0)
            || (scanFrequency == 4 && mApp.isScanFinished() == false && updatedStartCount % 20 == 0)) {

        buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text);
        buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info);
        buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout);

        buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryInfoText.setPaintFlags(
                buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
        buildingLibraryMainText.setPaintFlags(
                buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

        initScanProcess(1);

    } else {

        //Check if this activity was called from Settings.
        if (getIntent().hasExtra("UPGRADE")) {
            if (getIntent().getExtras().getBoolean("UPGRADE") == true) {
                mExplicitShowTrialFragment = true;
            } else {
                mExplicitShowTrialFragment = false;
            }

        }

        //initInAppBilling();
        launchMainActivity();
    }

    //Fire away a report to Google Analytics.
    try {
        if (mApp.isGoogleAnalyticsEnabled() == true) {
            EasyTracker easyTracker = EasyTracker.getInstance(this);
            easyTracker.send(MapBuilder.createEvent("Genesis Music startup.", // Event category (required)
                    "User started Genesis Music.", // Event action (required)
                    "User started Genesis Music.", // Event label
                    null) // Event value
                    .build());
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.keysolutions.ddpclient.android.DDPStateSingleton.java

/**
 * Constructor for class (hidden because this is a singleton)
 * @param context Android application context
 * @param meteorServer String containing the meteor server ie: demoparties.meteor.com
 * @param meteorPort Integer of the meteor server port ie: 80
 *///  w  ww  .  j a va 2  s  .c o m
public DDPStateSingleton(Context context, String meteorServer, Integer meteorPort) {
    if (TRACE)
        Log.v("DDPStateSingleton", "DDPStateSingleton - " + "context = [" + context + "], meteorServer = ["
                + meteorServer + "], meteorPort = [" + meteorPort + "]");
    this.mContext = context;
    this.mMeteorServer = meteorServer;
    this.mMeteorPort = meteorPort;
    //if (meteorServer != null) this.setServer(meteorServer);
    //if (meteorPort   != null) this.setServerPort(meteorPort);

    createDDPClient();
    // disable IPv6 if we're running on Android emulator because websocket
    // library doesn't work with it
    if ("google_sdk".equals(Build.PRODUCT)) {
        java.lang.System.setProperty("java.net.preferIPv6Addresses", "false");
        java.lang.System.setProperty("java.net.preferIPv4Stack", "true");
    }
    // kick off a connection before UI starts up
    isConnected();
}