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.

Open url with browser if button clicked Android example.

Button, setOnClickListener, Intent.ACTION_VIEW, startActivity Android example.


Button mIdButtonHome = (Button)findViewById(R.id.idButtonHome);
	mIdButtonHome.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			Intent browserIntent = new Intent(
					Intent.ACTION_VIEW,
					Uri.parse("//android.okhelp.cz/category/software/"));
			startActivity(browserIntent);
		}
	});



396LW NO topic_id




AD

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


152

Copy save Bitmap Image Pictures Android example | save-bitmap-image-android-example


Copy file to another

        File path = Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_PICTURES);
        File file = new File(path, "MyPicture.jpg");
           // the Pictures directory exists? 
            path.mkdirs();
            InputStream is = getResources().openRawResource(R.drawable.flower_blue);
            OutputStream os = new FileOutputStream(file);
            byte[] data = new byte[is.available()];
            is.read(data);
            os.write(data);
            is.close();
            os.close();


Copy and compress file

Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),
					R.drawable.flower_blue);

try {
	 FileOutputStream out = new FileOutputStream("new_bitmap.jpg");
		bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 90, out);
} catch (Exception e) {
	e.printStackTrace();
	Log.e("saveBitmap", e.getMessage());
} 
394

Download file from root Android device Windows | download-file-from-root-android-device-windows


Download file from Android device using Android Studio

stackoverflow.com/questions/34603355/android-device-monitor-data-folder-is-empty

C:\Users\user>c:\Users\user\AppData\Local\Android\sdk\platform-tools\adb shell (press Enter)
shell@Kraft-A6000:/ $ 
shell@Kraft-A6000:/ $ su (Enter)
root@Kraft-A6000:/ #
root@Kraft-A6000:/ # su -c "chmod 777 /data" (Enter)
root@Kraft-A6000:/ # su -c "chmod 777 /data/data" (Enter)
root@Kraft-A6000:/ # su -c "chmod 777 /data/data/com.your_package" (Enter)
root@Kraft-A6000:/ # su -c "chmod 777 /data/data/com.your_package/databases" (Enter)
root@Kraft-A6000:/ # su -c "chmod 777 /data/data/com.your_package/databases/database_name.db" (Enter)


  • Open Android Studio -> Tools -> Android -> Android Device Monitor (meybe some message box, minimalize all windows to find message box - close message box )
  • Pull data from Explorer

Date: 13.07.2020 - 08:23
154

Create own custom Title Bar TitleBar with a Icon Android example | create-own-custom-title-titlebar-android-example


onCreate in MainActivity.java

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

        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.main.xml);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
}


You can add to titlebar different Views by xml file.
custom_title.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="//schemas.android.com/apk/res/android" android:id="@+id/screen"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:orientation="vertical">
    <TextView android:id="@+id/left_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:text="Some text" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
       
        android:src="@drawable/ic_launcher" />
    
</RelativeLayout>





android/custom-title-titlebar-android.png
238

Admob ads not visible on emulator Android 4.1 | admob-ads-not-visible-on-emulator-android-4-1


If you using GoogleAdMobAdsSdk-4.0.4.jar in your project and set android:targetSdkVersion="17" in AndroidManifest.xml , ads will not visible on emulator with Android 4.0.3 or 4.1.
You have to set as android:targetSdkVersion="17"


<uses-sdk android:minSdkVersion="4" 
        android:targetSdkVersion="17" />


Update project.properties file - row with target to 17:

# Project target.
target=android-17
21

How to install mount SD card for Eclipse Android Emulator | how-install-sd-card-on-android-eclipse-emulator


If you want download some *.apk file from internet and try on your emulator you get error than you have to install SD card. You have to closing Android emulator.
Mount Android emulator SD card instruction

  1. In Eclipse go in menu Window - Android SDK and Avg Manager

  2. Select Virtual devices

  3. Select AVD Name where you need install SD card

  4. Click on Edit button

  5. In open dialog go to SD card - Size: and write 500

  6. Press button Edit AVD

  7. Run AVD emulator


Image how install SD card on Android emulator in Eclipse.