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.

Bitmap get Bitmap from resource Android example



PNG, GIF, BMP, JPG

// //www.apache.org/licenses/LICENSE-2.0

// 1.)  Bitmap from stream
            InputStream is = context.getResources().openRawResource(R.drawable.my_image);
            mBitmap = BitmapFactory.decodeStream(is);
           

// 2.) 
            Bitmap ball = BitmapFactory.decodeResource(getResources(), R.drawable.ball);
            int dstWidth =120;
            int dstHeight = 120;
            mBitmap = Bitmap.createScaledBitmap(ball, dstWidth, dstHeight, true);

// 3.)
Bitmap  mBitmap = Bitmap.createBitmap(320, 480, Bitmap.Config.ARGB_8888);


        Bitmap  mBitmap;
        Canvas  mCanvas;
        Paint   mBitmapPaint;
            
            mBitmap = Bitmap.createBitmap(320, 480, Bitmap.Config.ARGB_8888);
            mCanvas = new Canvas(mBitmap);
            mBitmapPaint = new Paint(Paint.DITHER_FLAG);

// 4.)
          Bitmap  mBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565);
          Canvas  mCanvas.setBitmap(mBitmap);
            mCanvas.drawColor(0xFFFFFFFF);


397LW NO topic_id



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


194

Samsung Galaxy Pocket - Android | samsung-galaxy-pocket-android


Nejmenší telefon od Samsungu s Androidem se někdy přidává i jako dárek k zakoupenému zboží, přesto tento telefon toho za svou cenu něco přes 2 000 korun umí hodně.
Technické parametry Samsung Galaxy Pocket
Rozměry a hmotnost: 103,70 × 57,50 × 12 mm, 97 g
Sítě GSM 850 / 900 / 1800 / 1900 MHz, W-CDMA (3G) 900 MHz / 2 100 MHz
Displej TFT TN, 2,80" (320 × 240 px), dotykový: kapacitní
Procesor 832 MHz
Paměť RAM 256 MB, vnitřní paměť 3 GB, paměťové karty microSD
Operační systém Android 2.3, údajně nelze upgradovat
Hudba: mp3, aac, wav, wma
Video: mp4, 3gp, 320 × 240 px, 15 FPS
Fotoaparát 2 Mpx
Navigace vestavěná GPS, elektronický kompas
Baterie 1 200 mAh, pohotovostní doba: 312 hodin
Cena něco přes 2 000 korun / léto 2012

samsung-galaxy-pocket
193

configChanges value of the com.google.ads.AdActivity must include | configchanges-value-of-the-com-google-ads-adactivity-must-include


Errors:
E/Ads(333): The android:configChanges value of the com.google.ads.AdActivity must include screenLayout.
E/Ads(333): The android:configChanges value of the com.google.ads.AdActivity must include uiMode.
E/Ads(333): The android:configChanges value of the com.google.ads.AdActivity must include screenSize.
E/Ads(333): The android:configChanges value of the com.google.ads.AdActivity must include smallestScreenSize.
E/Ads(333): You must have AdActivity declared in AndroidManifest.xml with configChanges.

Solution:
Try to using a lower version of the GoogleAdMobAdsSDK ADS SDK in project:
GoogleAdMobAdsSDK-4.0.4
How add SDK to project

Add activity to AndroidManifest.xml


// .............. blah
    <uses-sdk android:minSdkVersion="4"/>
   <uses-permission android:name="android.permission.INTERNET" />
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application android:icon="@drawable/dicts_ico" android:label="@string/app_name" 
    >
           <meta-data 
        android:value="a12345_your_number" 
        android:name="ADMOB_PUBLISHER_ID" />
        <activity android:name=".MainStartMenu"
                  android:label="@string/app_name"
                  android:configChanges="keyboardHidden|orientation"
                  >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


  <!-- Google ads -->      
<activity android:name="com.google.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation"/>

// ......... blah 
132

Draw circle Android basic example | draw-circle-android-basic-example


Canvas, drawCircle(), Paint, onDraw(), setStrokeWidth(), setStyle()

public class MainActivity extends Activity {
	@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) {

			canvas.drawColor(Color.CYAN);
			Paint p = new Paint();
			// smooths
			p.setAntiAlias(true);
			p.setColor(Color.RED);
			p.setStyle(Paint.Style.STROKE); 
			p.setStrokeWidth(4.5f);
			// opacity
			//p.setAlpha(0x80); //
			canvas.drawCircle(50, 50, 30, p);
		}

	}
}

63

Date time difference determine which is earlier Android Java example | date-time-difference-between-two-dates


Date difference in millisecond between two date, GregorianCalendar, Calendar, after(), befor(), getTimeInMillis().



public class HoriziontalScrollActivity extends Activity {
TextView txtV;
	Context cntx;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        txtV = (TextView)findViewById(R.id.idLabel);
        cntx = this;
        StringBuilder strBuild = new StringBuilder();
        Calendar firstDate = new GregorianCalendar(2011, Calendar.DECEMBER, 31);
        Calendar secondDate = new GregorianCalendar(2012, Calendar.JANUARY, 1);

        
        Boolean bDetermine = firstDate.after(secondDate);            // false
        strBuild.append("Is firsDate after secondDate? " + bDetermine + "

"); bDetermine = firstDate.before(secondDate); // true strBuild.append("Is firsDate before secondDate? " + bDetermine + "
"); long differenceInMillisecond = 0L; differenceInMillisecond = secondDate.getTimeInMillis()-firstDate.getTimeInMillis(); // second == 1000 millisecond long second = differenceInMillisecond / 1000L; strBuild.append("Difference between two dates is: " + second + "
"); txtV.setText(strBuild); } }
211

Chrome youtube shockwave flash plugin crashes solution | chrome-shockwave-flash-plugin-crashes


Google Chrome and Shockwave Flash crashes on youtube.com

  • open chrome://plugins/ with Google Chrome

  • click on Plus button for more details

  • find Flash (3 files)
  • disable two other Shockwave Flash

  • for more see image below



google-chrome-flash-crash-solution-1

google-chrome-flash-crash-solution-2


Editace Jana Žákovská : 2013-12-09 13:12:32
Počet článků v kategorii: 397
Url:bitmap-get-bitmap-from-resource-android-example
Share
Share
Tweet