Kivy is a open source Python library for rapid development, runs on Linux, Windows, OS X, Android, iOS, and Raspberry Pi. You can run the same code on all supported platforms.
You can run Kivy applications on Android, on (more or less) any device with OpenGL ES 2.0 (Android 2.2 minimum). This is standard on modern devices; Google reports the requirement is met by 99.9% of devices.
Kivy APKs are normal Android apps that you can distribute like any other, including on stores like the Play store. They behave properly when paused or restarted, may utilise Android services and have access to most of the normal java API.
Here at IFA 2019, Huawei introduced the world's first 5G system on a chip; the Kirin 990. The company also showed off a new set of truly wireless earbuds, featuring wireless charging, and active noise cancellation.
Huawei launched official website for Ark Compiler (方舟编译器) on August 31. The Open Ark Compiler, Huawei’s application compiler, works to improve the compilation efficiency of Android apps by directly interpreting and executing the machine code/binary code to the system language target HarmonyOS.
Currently, The Ark Compiler web site is in Chinese only.The English version of the website will go live in Q4 2019.
Collections are a common concept for most programming languages. The Kotlin Standard Library provides a comprehensive set of tools for managing collections – groups of a variable number of items (possibly zero) that share significance to the problem being solved and are operated upon commonly.
Check the ultimate guide, Kotlin Collections Overview, with 18 sections that cover everything from the basic essentials to mastery.
The free online course Developing Android Apps with Kotlin, was developed by Google with Udacity. You'll learn how to build Android apps using industry-standard tools and libraries in the Kotlin programming language.
In this free course, you will learn the fundamentals of building Android applications using Kotlin. The course covers architecture components, multi-screen navigation, data persistence, RESTful APIs and Material Design. By the end of the course, you’ll be able to create well-designed Android applications using Kotlin that can connect to the internet, store data and navigate between screens.
At Google I/O'19, Google announced Android development will become increasingly Kotlin-first. Many new Jetpack APIs and features will be offered first in Kotlin. If you’re starting a new project, you should write it in Kotlin.
What's New in Kotlin on Android, 2 Years In (Google I/O'19)
This session examines the progress made in Android support for Kotlin. This talk will cover Kotlin samples and reference docs, annotations, framework APIs, IDE support for low-level bytecode optimizations in the D8/R8 compiler, and work on the Kotlin Foundation.
This recommended video from Google I/O 2018 help developers understand how new APIs and features work together and learn what should use to build solid, modern Android applications.
By default, Oracle VirtualBox support USB 1.1 only. This video show how to enable USB 2.0/3.0 for VirtualBox 6.0.4/Windows 10 by installing VirtualBox Extension Pack.
Visit VirtualBox Downloads page, scroll down to download and install VirtualBox 6.0.4 Oracle VM VirtualBox Extension Pack.
Support for USB 2.0 and USB 3.0 devices, VirtualBox RDP, disk encryption, NVMe and PXE boot for Intel cards. See this chapter from the User Manual for an introduction to this Extension Pack. The Extension Pack binaries are released under the VirtualBox Personal Use and Evaluation License (PUEL). Please install the same version extension pack as your installed version of VirtualBox.
Android Q beta 2 contains stronger protections for user privacy along with new ways to engage users including bubbles. Dan Galpin highlights many of the changes in both the Q beta 1 and 2 releases, including extended support for foldables, faster ShareSheets with updated direct sharing, and high performance features such as Vulkan 1.1. Android Q beta 2 is now available on all Pixel devices.
The Navigation component is a suite of libraries, tooling and guidance for in-app navigation. The component centralizes all of the navigation information of your app in a navigation graph, providing a robust framework for implementing everything from simple button clicks to complex navigation UI patterns.
Android Studio 3.3 includes the Navigation Editor, which visuals your navigation graph. Other features and benefits include:
- Automatic handling of fragment transactions
- Correctly handling up and back
- Default behaviors for animations and transitions
- Deep linking, including proper backstack generation
- Implementing common patterns like navigation drawers and bottom nav with little additional work using the Navigation UI library → http://bit.ly/2EWYtoV
- Type safety when passing information while navigating using the Safe Args plugin → http://bit.ly/2VR7kPM
With latest Android Studio, I change the targetSdkVersion and compileSdkVersion of my old exercise to 28. And I also have to use updated com.android.support:appcompat-v7 and com.android.support.constraint:constraint-layout. After fail in rebuild, it's a number of WARNING and ERROR.
----------------------------- ERROR: Failed to resolve: com.android.support:appcompat-v7:28.0.0 Add Google Maven repository and sync project Show in Project Structure dialog Affected Modules: app ERROR: Failed to resolve: com.android.support.constraint:constraint-layout:1.1.3 Add Google Maven repository and sync project Show in Project Structure dialog Affected Modules: app WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html Affected Modules: app WARNING: Configuration 'testCompile' is obsolete and has been replaced with 'testImplementation'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html Affected Modules: app WARNING: Configuration 'androidTestCompile' is obsolete and has been replaced with 'androidTestImplementation'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html Affected Modules: app
-----------------------------
As suggested, I change 'compile', 'testCompile' and 'androidTestCompile' to 'implementation', 'testImplementation' and 'androidTestImplementation', in app/build.gradle.
To fix the error of Failed to resolve: com.android.support:appcompat-v7:28.0.0 and com.android.support.constraint:constraint-layout:1.1.3, I add the follow lines of Google Maven repository to build.gradle.
maven {
url 'https://maven.google.com/'
name 'Google'
}
And rebuild the project. At least it works for me now.
So, how to know the latest version of com.android.support:appcompat-v7 and com.android.support.constraint:constraint-layout?
28.0.0 is the recentest stable release of Support Library released on September 21, 2018 and will be the last feature release under the android.support packaging.
It's a reference to built-in XML layout that is part of the Android OS, HERE. Basically, all reference start with android.R is reference to Android built-in resource.
You can locate the source file in your development setup from Android Studio (BUT DON'T EDIT IT):
> Select it and right click > Go to > Declaration
Android Studio will open it for you, and the location will be shown on top bar.
It's a simple example to write image to External Storage, with targetSdkVersion = 28. It work as expected on devices running Android below 6, but fail on Android 6+! (Solution provided in second part below)
The above code fail when install on device running Android 6+! Because start from Android 6, your apps have to request user approve permissions at runtime. The following example show how to check and request permission at runtime. You still have to declare uses-permission of "android.permission.WRITE_EXTERNAL_STORAGE" in manifest.
When run on devices below Android 6, permission will be granted at install time. When run on Android 6+, you have to check permission at runtime before perform the task and ask user for approval if need.
package com.blogspot.android_er.androidwriteimage;
import android.Manifest;
import android.app.Activity;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
public class MainActivity extends AppCompatActivity {
final String MyAlbum = "android-er";
Bitmap bitmapSrc;
TextView tvSavedInfo;
Activity thisActivity;
final int MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
thisActivity = this;
tvSavedInfo = (TextView)findViewById(R.id.savedinfo);
dispTestCase();
//prepare dummy source of bitmap to save
Drawable drawable = getDrawable(R.mipmap.ic_launcher);
bitmapSrc = BitmapFactory.decodeResource(
getApplicationContext().getResources(),
R.mipmap.ic_launcher);
ImageView ivImage;
ivImage = findViewById(R.id.imageView1);
ivImage.setImageDrawable(drawable);
Button btnSave;
btnSave = (Button)findViewById(R.id.buttonSave);
btnSave.setOnClickListener(btnOnClickListener);
}
public File getPublicAlbumStorageDir(String albumName) {
// Get the directory for the user's public pictures directory.
File file = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES), albumName);
if (file.mkdirs()) {
//if directory not exist
Toast.makeText(getApplicationContext(),
file.getAbsolutePath() + " created",
Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(),
"Directory not created", Toast.LENGTH_LONG).show();
}
return file;
}
Button.OnClickListener btnOnClickListener = new Button.OnClickListener(){
@Override
public void onClick(View v) {
tvSavedInfo.setText("");
if (ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
// Permission is not granted
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(
thisActivity,
Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
//to simplify, call requestPermissions again
Toast.makeText(getApplicationContext(),
"shouldShowRequestPermissionRationale",
Toast.LENGTH_LONG).show();
ActivityCompat.requestPermissions(thisActivity,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
} else {
// No explanation needed; request the permission
ActivityCompat.requestPermissions(thisActivity,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
}
}else{
// permission granted
writeImage();
}
}
};
@Override
public void onRequestPermissionsResult(int requestCode,
@NonNull String[] permissions,
@NonNull int[] grantResults) {
if(requestCode == MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE){
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted.
Toast.makeText(getApplicationContext(),
"permission was granted, thx:)",
Toast.LENGTH_LONG).show();
} else {
// permission denied.
Toast.makeText(getApplicationContext(),
"permission denied! Oh:(",
Toast.LENGTH_LONG).show();
}
return;
}else{
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
private void writeImage(){
//generate a unique file name from timestamp
Date date = new Date();
SimpleDateFormat simpleDateFormat =
new SimpleDateFormat("yyMMdd-hhmmss-SSS");
String fileName = "img" + simpleDateFormat.format(new Date()) + ".jpg";
File dir = getPublicAlbumStorageDir(MyAlbum);
File file = new File(dir, fileName);
OutputStream outputStream = null;
try {
outputStream = new FileOutputStream(file);
bitmapSrc.compress(Bitmap.CompressFormat.JPEG, 80, outputStream);
outputStream.flush();
outputStream.close();
tvSavedInfo.setText("File saved: \n" + file.getAbsolutePath());
} catch (FileNotFoundException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(),
"FileNotFoundException: \n" + e.getMessage(),
Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(),
"IOException: \n" + e.getMessage(),
Toast.LENGTH_LONG).show();
}
}
private void dispTestCase(){
String testCase;
TextView tvTestCase;
tvTestCase = (TextView)findViewById(R.id.testcase);
testCase = "Tested on Android " + Build.VERSION.RELEASE + "\n";
PackageManager packageManager = getPackageManager();
String packageName = getPackageName();
int targetSdkVersion;
try {
PackageInfo packageInfo =
packageManager.getPackageInfo(packageName, 0);
ApplicationInfo applicationInfo = packageInfo.applicationInfo;
targetSdkVersion = applicationInfo.targetSdkVersion;
testCase += "targetSdkVersion = " + targetSdkVersion;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(),
"NameNotFoundException: " + e.getMessage(),
Toast.LENGTH_LONG).show();
}
tvTestCase.setText(testCase);
}
}
android.os.Build provide various information about the current build the devices, extracted from system properties. here is a simple example to get the manufacturer and model of the device, and the version of the Android.
It's a good web to try Kotlin for beginner, Kotlin Playground, an online sandbox to explore Kotlin
programming language. You can edit, run and share Kotlin code online, and also browse code samples directly in the browser.
The video show how to set Java version on Studio 3.3.1.
By default, the Java language version used to compile your project is based on your project's compileSdkVersion (because different versions of Android support different versions of Java). If necessary, you can override this default Java version by adding the following CompileOptions {} block to your build.gradle file:
You can also set using Android Studio menu:
- File > Project Structure.
- In Structure Project dialog, Select App on the left, and select Properties tab.
- You can see option boxes of Source Compatibility and Target Compatibility).
sourceCompatibility vs targetCompatibility
According to Gradle documentation:
JavaVersion sourceCompatibility - Java version compatibility to use when compiling Java source. Default value: version of the current JVM in use JavaVersion. Can also set using a String or a Number, e.g. '1.5' or 1.5.
JavaVersion targetCompatibility - Java version to generate classes for. Default value: sourceCompatibility. Can also set using a String or Number, e.g. '1.5' or 1.5.