Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

Get SensorManager PowerManager WindowManager Display Android example


AD MOB


    private SensorManager mSensorManager;
    private PowerManager mPowerManager;
    private WindowManager mWindowManager;
    private Display mDisplay;

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

       // Get an instance of the SensorManager
        mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

        // Get an instance of the PowerManager
        mPowerManager = (PowerManager) getSystemService(POWER_SERVICE);

        // Get an instance of the WindowManager
        mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
        mDisplay = mWindowManager.getDefaultDisplay();

        setContentView(R.layout.main); // main.xml or your xml file name

}


397LW NO topic_id




AD

Další témata ....(Topics)


15

int java android example | int-java-android-example


int occupy 4 bytes (32 bits) in memory

int in Java example of using Integer and Array of Integer and Iteger to String

        // get max end min values of int in Java example 4 bytes (32 bits) PC architecture
	System.out.println(Integer.MAX_VALUE); // 2147483647
	System.out.println(Integer.MIN_VALUE); // -2147483648


// members variable
private int mProgress = 10;

//integer to string java
int myInteger = 8;
String myString = Integer.toString(myInteger);

// a final variable can only be initialized once
static final int NUM_PARTICLES = 15;

 for (int i = 0; i < NUM_PARTICLES ; i++) { 
// do something
}

// int as return value of function
public int getCount() {
return 5;
}

// int as a parametr of function
public float getFloatFromInt(int i) {
float fRet = (float) i;
 return fRet;
}

//array of int
int[] anArray;              // declares an array of integers
          anArray = new int[2];      // allocates memory for 2 integers
          anArray[0] = 100; // initialize first element
          anArray[1] = 200; // initialize second element

for (int i = 0; i < anArray.length; i++) {
// print out values from anArray
System.out.println("Index: " + i);
System.out.println("Value: " + anArray[i]); 
}


139

drawBitmap createBitmap by array of colours Android example | drawbitmap-createbitmap-draw-bitmap-by-array-of-colours-android-example


public static Bitmap createBitmap (int[] colors, int offset, int stride, int width, int height, Bitmap.Config config)
public void drawBitmap (Bitmap bitmap, float left, float top, Paint paint)

//  //www.apache.org/licenses/LICENSE-2.0
public class MainActivity extends Activity {
	    private static final int WIDTH = 50;
	    private static final int HEIGHT = 50;
	    private static final int STRIDE = 64;   // must be >= WIDTH
	    
	    private static int[] createColors() {
	        int[] colors = new int[STRIDE * HEIGHT];
	        for (int y = 0; y < HEIGHT; y++) {
	            for (int x = 0; x < WIDTH; x++) {
	                int r = x * 255 / (WIDTH - 1);
	                int g = y * 255 / (HEIGHT - 1);
	                int b = 255 - Math.min(r, g);
	                int a = Math.max(r, g);
	                colors[y * STRIDE + x] = (a << 24) | (r << 16) | (g << 8) | b;
	            }
	        }
	        return colors;
	    }
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}

	private static class SampleView extends View {

		// CONSTRUCTOR
		public SampleView(Context context) {
			super(context);
			setFocusable(true);

		}
		@Override
		protected void onDraw(Canvas canvas) {
			Paint paint = new Paint();
			
			canvas.drawColor(Color.GREEN);

            int[] mColors = createColors();
            int[] colors = mColors;

           
            Bitmap bitmap = Bitmap.createBitmap(colors, 0, STRIDE, WIDTH, HEIGHT,
                    Bitmap.Config.RGB_565);
                      
			canvas.drawBitmap(bitmap, 50,20, paint); 
		}

	}
}


318

Admob ad not visible on Android Emulator | admob-ad-not-visible-on-android-emulator


Try this solution:
  				
AdView adView = new AdView(getApplicationContext());//in menu inflater getActivity()
adView.setAdUnitId("ca-app-pub-87***yourNumber");
adView.setAdSize(AdSize.BANNER); 					
LinearLayout linLay = (LinearLayout)findViewById(R.id.idReklamaLayout);
// Add the adView to it
linLay.addView(adView);
// Initiate a generic request to load it with an ad
if(Build.MANUFACTURER.equals("unknown")) {
// Emulator
AdRequest.Builder.addTestDevice("B3EEABB8EE11C2BE770B684D95219ECB"); // to get test ads on this device.
AdRequest adRequest = new AdRequest.Builder()
 .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)        // All emulators
 .addTestDevice("B3EEABB8EE11C2BE770B684D95219ECB")  // Emulator id you will get in the LogCat verbose
 .build();
			
adView.loadAd(adRequest);
	  			/* */
}else {
 // Not Emulator
// Initiate a generic request to load it with an ad
AdRequest adRequest = new AdRequest.Builder().build();   
adView.loadAd(adRequest);/**/
}


308

ADT Bundle 22.6.2 have memory leak. | adt-bundle-22-6-2-have-memory-leak


If I trying
android-sdk_r22.6.2-windows.zip
adt-bundle-windows-x86_64-20140321.zip
and open xml layout graphic editor and xml layout file
memory continues to grow to crashes Eclipse

https://developer.android.com/sdk/index.html

I have to install old version adt-bundle-windows-x86-20131030.zip
what working fine.
I had to delete .metadata folder in workspace if I want open old version ADT
181

Motorola Droid X | motorola-droid-x


Motorola Droid X cena od 3 000 KCZ Kč (únor.2012)
Spokojenost uživatelů nadprůměrná.
Motorola Droid X je chytrý telefon s operačním systémem Android.
Motorola Droid X je (22.února2012) 8. nejpoužívanějším chytrým telefonem u programu Sky Map viz tabulka.

Android 2.1
Display 854 x 480 pixelů
8 megapixel fotoaparát dual LED flash
720p HD video recording
Music and Video player
8 GB paměť
rozšíření paměti 32 GB
WiFi/DLNA
TI OMAP3630 processor – 1GHz
4.3-inch large display

Motorola Droid X photo pic image
Motorola Droid X
Zdroj obrázku: wikipedia


Editace: 2011-11-07 11:43:11
Počet článků v kategorii: 397
Url:get-sensormanager-powermanager-windowmanager-display-android-example

AD
11 Share
Share
Tweet