Determine Set Out Of Processor Cores

Posted on

Runtime.availableProcessors() returns the reveal of processor cores available to the VM, at to the lowest degree 1. Traditionally this returned the reveal currently online, precisely many mobile devices are able to accept unused cores offline to relieve power, together with then releases newer than Android 4.2 (Jelly Bean) provide the maximum reveal of cores that could last made available if in that place were no ability or rut constraints.

Example:

package com.blogspot.android_er.androidnumberofcores;  import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView;  populace flat MainActivity extends AppCompatActivity {      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);          int availableCores = Runtime.getRuntime().availableProcessors();         TextView textViewNumOfCores = (TextView)findViewById(R.id.numofcore);         textViewNumOfCores.setText("Available Processors: " + availableCores);     } }  

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:padding="16dp"     android:orientation="vertical"     tools:context="com.blogspot.android_er.androidnumberofcores.MainActivity">      <TextView         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_horizontal"         android:autoLink="web"         android:text="https://rootandroid.org//"         android:textStyle="bold" />      <TextView         android:id="@+id/numofcore"         android:layout_width="match_parent"         android:layout_height="wrap_content" /> </LinearLayout>  

4 cores on Xiaomi Redmi 2

single inwardness on Android Emulator