This repository contains complete code for Android blog posts on hmkcode.com
hmkcode / android Goto Github PK
View Code? Open in Web Editor NEWAndroid related examples
Android related examples
This repository contains complete code for Android blog posts on hmkcode.com
Hi. I'm doing a Android Studio Project, with some AsyncTasks, and at some point it gives me the error at the Title. I know that i really can't use method getText it in doInBackground, but i've tried to do the recommended changes from another questions, to the code and nothing seems to work. This is my code:
`public class LoginActivity extends AppCompatActivity {
Button btSignIn;
Button btSignUp;
EditText edtEmail;
EditText edtPassword;
String CHANNEL_ID = "personal_notification";
int NOTIFICATION_ID = 001;
UserDatabase database;
UserDao userDao;
User userTemp = new User();
SharedPreferences emailSharedPref;
ProgressDialog progressDialog, progressDialogDownload;
@Override
protected void onStart() {
super.onStart();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
Log.d("MYTAG", "inicio ");
progressDialog = new ProgressDialog(this);
progressDialog.setCancelable(false);
progressDialog.setMessage("A verificar utilizador...");
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setProgress(0);
database = Room.databaseBuilder(getApplicationContext(), UserDatabase.class, "mi-database.db").build();
userDao = database.getUserDao();
btSignIn = findViewById(R.id.btSignIn);
btSignUp = findViewById(R.id.btSignUp);
edtEmail = findViewById(R.id.email);
edtPassword = findViewById(R.id.password);
btSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(LoginActivity.this, SignUpActivity.class));
}
});
btSignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LoadAsyncTaskLogin loadAsyncTaskLogin = new LoadAsyncTaskLogin();
loadAsyncTaskLogin.execute(userTemp);
}
});
}
public class LoadAsyncTaskLogin extends AsyncTask<User, Void, User> {
@Override
protected User doInBackground(User... users) {
String email = edtEmail.getText().toString();
String password = edtPassword.getText().toString();
User user2 = new User();
user2 = database.getUserDao().getUser(email,password);
return user2;
}
@Override
protected void onPostExecute(User user2){
Intent intentToWhatToChoose = new Intent(LoginActivity.this,WhatToChoose.class);
if(user2 != null){
if(user2.password.equals(edtPassword.getText().toString())){
emailSharedPref = getApplicationContext().getSharedPreferences("email",0);
SharedPreferences.Editor editor = emailSharedPref.edit();
editor.putString("User Successfully Logged In",user2.email);
editor.commit();
startActivity(intentToWhatToChoose);
Toast.makeText(LoginActivity.this, "Welcome to Our App", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(LoginActivity.this, "Incorrect Credentials", Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(LoginActivity.this, "Incorrect Credentials", Toast.LENGTH_LONG).show();
}
}
}`
The error is on "doInBackground". What changes do i have to do?
Hi, I'm making an app with a music widget it has the following buttons.
Play, Pause, Previous track and Next track.
how do I play music in the google play music app just by pressing the play button?
any help would be appreciated thankyou.
I am trying to creat an app, and I inserted runOnUIThread()
thinking that it would resolve the error:
Accessibility content change on non-UI thread.
How come? My app is even crashing.
Please help me.
we want the animation tutorial, i.e fill animation from source point.
how would you use the custom adapter if you are fetching data from the db for the first textview and instead of the second textview,you use an edittext which should set data to the db
I am creating another app but the following error is occurring:
2023-11-13 20:46:10.288 20988-20988 AndroidRuntime com.education.quizie D Shutting down VM
2023-11-13 20:46:10.289 20988-20988 AndroidRuntime com.education.quizie E FATAL EXCEPTION: main
Process: com.education.quizie, PID: 20988
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.education.quizie/com.education.quizie.MainActivity}: java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3426)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3575)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:137)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2131)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7554)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)
Caused by: java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup
at android.view.ViewGroup.addView(ViewGroup.java:4930)
at android.view.ViewGroup.addView(ViewGroup.java:4912)
at com.education.quizie.MainActivity.onCreate(MainActivity.java:168)
at android.app.Activity.performCreate(Activity.java:7815)
at android.app.Activity.performCreate(Activity.java:7804)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1308)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3401)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3575)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:137)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2131)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7554)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)
2023-11-13 20:46:10.345 20988-20988 Process com.education.quizie I Sending signal. PID: 20988 SIG: 9
---------------------------- PROCESS ENDED (20988) for package com.education.quizie ----------------------------
2023-11-13 20:46:10.243 20988-20988 ducation.quizi com.education.quizie W Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2023-11-13 20:46:10.244 20988-20988 ducation.quizi com.education.quizie W Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2023-11-13 20:46:10.288 20988-20988 AndroidRuntime com.education.quizie D Shutting down VM
2023-11-13 20:46:10.289 20988-20988 AndroidRuntime com.education.quizie E FATAL EXCEPTION: main
Process: com.education.quizie, PID: 20988
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.education.quizie/com.education.quizie.MainActivity}: java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3426)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3575)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:137)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2131)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7554)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)
Caused by: java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup
at android.view.ViewGroup.addView(ViewGroup.java:4930)
at android.view.ViewGroup.addView(ViewGroup.java:4912)
at com.education.quizie.MainActivity.onCreate(MainActivity.java:168)
at android.app.Activity.performCreate(Activity.java:7815)
at android.app.Activity.performCreate(Activity.java:7804)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1308)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3401)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3575)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:137)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2131)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7554)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)
2023-11-13 20:46:10.345 20988-20988 Process com.education.quizie I Sending signal. PID: 20988 SIG: 9
My code:
package com.education.quizie;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.widget.ViewSwitcher;
import java.io.File;
public class MainActivity extends AppCompatActivity {
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
if (!(new File("Progress.data").exists())) {
new File("Progress.data").createNewFile();
JaScri.writeFile("Progress.data", "UTF-8", "MDA=");
}
if (!(new File("btn").exists())) {
new File("btn").createNewFile();
JaScri.writeFile("btn", "UTF-8", "dHJ1ZQ==");
}
if (!(new File("btn2").exists())) {
new File("btn2").createNewFile();
JaScri.writeFile("btn2", "UTF-8", "dHJ1ZQ==");
}
if (!(new File("btn3").exists())) {
new File("btn3").createNewFile();
JaScri.writeFile("btn3", "UTF-8", "dHJ1ZQ==");
}
if (!(new File("btn4").exists())) {
new File("btn4").createNewFile();
JaScri.writeFile("btn4", "UTF-8", "dHJ1ZQ==");
}
if (!(new File("btn5").exists())) {
new File("btn5").createNewFile();
JaScri.writeFile("btn5", "UTF-8", "dHJ1ZQ==");
}
if (!(new File("GK").exists())) {
new File("GK").createNewFile();
JaScri.writeFile("GK", "UTF-8", "What is the capital of Australia?\n" +
"Who wrote the novel \"Pride and Prejudice\"?\n" +
"What is the chemical symbol for gold?\n" +
"Who painted the Mona Lisa?\n" +
"What is the currency of Japan?");
}
if (!(new File("GK-A").exists())) {
new File("GK-A").createNewFile();
JaScri.writeFile("GK-A", "UTF-8", "Canberra\n" +
"Jane Austen\n" +
"Au\n" +
"Leonardo da Vinci\n" +
"Japanese Yen (JPY)");
}
if (!(new File("GK-I").exists())) {
new File("GK-I").createNewFile();
JaScri.writeFile("GK-I", "UTF-8", "Sydney\n" +
"John Steinbeck\n" +
"Go\n" +
" Vincent Van Gogh\n" +
"Japanese Yan (JPY)");
}
if (!(new File("Imp").exists())) {
new File("Imp").createNewFile();
JaScri.writeFile("Imp", "UTF-8", "What is consciousness?\n" +
"Is there a pattern in numbers?\n" +
"Can problems be solved as fast as they're checked?\n" +
"How do fluids behave?\n" +
"Can all forces be in one theory?");
}
if (!(new File("Imp-A").exists())) {
new File("Imp-A").createNewFile();
JaScri.writeFile("Imp-A", "UTF-8", "Brain's mystery.\n" +
"Uncovered regularities.\n" +
"Faster solutions?\n" +
"Liquid & gas motion.\n" +
"Single universal theory.");
}
if (!(new File("Imp-I").exists())) {
new File("Imp-I").createNewFile();
JaScri.writeFile("Imp-I", "UTF-8", "Brain's part.\n" +
"Yes\n" +
"Slower solutions\n" +
"no motion.\n" +
"No");
}
if (!(new File("IT").exists())) {
new File("IT").createNewFile();
JaScri.writeFile("IT", "UTF-8", "DDoS protection.\n" +
"Server virtualization benefits.\n" +
"Encryption types in cybersecurity.\n" +
"SQL injection risks.\n" +
"Cloud computing and migration factors.");
}
if (!(new File("IT-A").exists())) {
new File("IT-A").createNewFile();
JaScri.writeFile("IT-A", "UTF-8", "Defense against attacks.\n" +
"IT advantages.\n" +
"Symmetric and asymmetric methods.\n" +
"Security risk.\n" +
"Business benefits and migration.");
}
if (!(new File("IT-I").exists())) {
new File("IT-I").createNewFile();
JaScri.writeFile("IT-I", "UTF-8", "Not manage packages\n" +
"faster processing\n" +
"Symmetric method.\n" +
"Computer Breach.\n" +
"Business benefits and performance.");
}
if (!(new File("Math").exists())) {
new File("Math").createNewFile();
JaScri.writeFile("Math", "UTF-8", "Solve for x: 3x^2 - 5x + 2 = 0\n" +
"Simplify: (2x^3y^4)(-3x^2y^2)\n" +
"Factor the expression: 3x^2 - 12x\n" +
"Solve for x and y: 2x + 3y = 11; 4x - 5y = 1\n" +
"Find the x value: |2x - 7| = 9?");
}
if (!(new File("Math-A").exists())) {
new File("Math-A").createNewFile();
JaScri.writeFile("Math-A", "UTF-8", "x = 1 and x = 2/3\n" +
"-6x^5y^6\n" +
"3x(x - 4)\n" +
"x = 3, y = 2\n" +
"x = 8 & x = -1");
}
if (!(new File("Math-I").exists())) {
new File("Math-I").createNewFile();
JaScri.writeFile("Math-I", "UTF-8", "x = 1\n" +
"6x^5y^6\n" +
"3x(x - 3)\n" +
"x = 3, y = 4\n" +
"x = 8 & x = 1");
}
if (!(new File("Science").exists())) {
new File("Science").createNewFile();
JaScri.writeFile("Science", "UTF-8", "What is the Heisenberg Uncertainty Principle?\n" +
"Explain exothermic and endothermic reactions.\n" +
"Define gene splicing in genetic engineering.\n" +
"Describe black holes.\n" +
"Explain plate tectonics.");
}
if (!(new File("Science-A").exists())) {
new File("Science-A").createNewFile();
JaScri.writeFile("Science-A", "UTF-8", "Uncertainty in particle position and momentum.\n" +
"Exothermic (heat out), endothermic (heat in).\n" +
"Alters traits with DNA mixing.\n" +
"Super-gravity traps all, including light.\n" +
"Plates move, shape land, shake, uplift mountains.");
}
if (!(new File("Science-I").exists())) {
new File("Science-I").createNewFile();
JaScri.writeFile("Science-I", "UTF-8", "Uncertainty in particle speed and momentum.\n" +
"Exothermic (cool out), endothermic (heat in).\n" +
"DNA mixing.\n" +
"Super-gravity traps all, but light.\n" +
"Plates move, shape land, uplift mountains.");
}
} catch (Exception e) {
//Do nothing
}
ViewSwitcher v = (ViewSwitcher) findViewById(R.id.views);
v.addView(findViewById(R.id.main));
}
}
&
package com.education.quizie;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
import java.util.Scanner;
public class QuizieMain extends AppCompatActivity {
public static int score;
public static String[][] questions = new String[5][5];
public static String[][] answers = new String[5][5];
public static String[][] inanswers = new String[5][5];
public static int[][] seq = {{1, 0, 1, 1, 0}, {0, 1, 1, 0, 0}, {1, 0, 0, 0, 1}, {0, 1, 1, 0, 1}, {1, 1, 0, 1, 0}};
int i = 0;
public static int[] marks = {10, 10, 10, 10, 60};
public static int qi = 0;
{
try {
score = Integer.parseInt(JaScri.base64("decode", JaScri.readFile("./Progress.data")));
} catch (FileNotFoundException | ConversionTypeNotFound | UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quizie_main);
Button gk = (Button) findViewById(R.id.button);
Button math = (Button) findViewById(R.id.button2);
Button science = (Button) findViewById(R.id.button3);
Button it = (Button) findViewById(R.id.button4);
Button adv = (Button) findViewById(R.id.button5);
TextView ScoreView = (TextView) findViewById(R.id.textView3);
try {
gk.setEnabled(Boolean.parseBoolean(JaScri.base64("decode", JaScri.readFile("btn"))));
math.setEnabled(Boolean.parseBoolean(JaScri.base64("decode", JaScri.readFile("btn2"))));
science.setEnabled(Boolean.parseBoolean(JaScri.base64("decode", JaScri.readFile("bn3"))));
it.setEnabled(Boolean.parseBoolean(JaScri.base64("decode", JaScri.readFile("btn4"))));
adv.setEnabled(Boolean.parseBoolean(JaScri.base64("decode", JaScri.readFile("btn5"))));
} catch (ConversionTypeNotFound | UnsupportedEncodingException | FileNotFoundException e) {
throw new RuntimeException(e);
}
gk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startQuiz(0);
}
});
math.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startQuiz(1);
}
});
science.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startQuiz(2);
}
});
it.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startQuiz(3);
}
});
adv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startQuiz(4);
}
});
Save();
File file = new File("GK.txt");
Scanner reader;
try {
reader = new Scanner(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
StringBuilder content = new StringBuilder();
while (reader.hasNextLine()) {
String data = reader.nextLine();
content.append(data).append("\n");
questions[0][i] = data;
i++;
}
i = 0;
file = new File("Math.txt");
try {
reader = new Scanner(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
while (reader.hasNextLine()) {
String data = reader.nextLine();
content.append(data).append("\n");
questions[1][i] = data;
i++;
}
i = 0;
file = new File("Science.txt");
try {
reader = new Scanner(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
while (reader.hasNextLine()) {
String data = reader.nextLine();
content.append(data).append("\n");
questions[2][i] = data;
i++;
}
i = 0;
file = new File("IT.txt");
try {
reader = new Scanner(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
while (reader.hasNextLine()) {
String data = reader.nextLine();
questions[3][i] = data;
i++;
}
i = 0;
file = new File("Imp.txt");
try {
reader = new Scanner(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
while (reader.hasNextLine()) {
String data = reader.nextLine();
questions[4][i] = data;
i++;
}
i = 0;
file = new File("GK-A.txt");
try {
reader = new Scanner(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
content = new StringBuilder();
while (reader.hasNextLine()) {
String data = reader.nextLine();
content.append(data).append("\n");
answers[0][i] = data;
i++;
}
i = 0;
file = new File("Math-A.txt");
try {
reader = new Scanner(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
while (reader.hasNextLine()) {
String data = reader.nextLine();
content.append(data).append("\n");
answers[1][i] = data;
i++;
}
i = 0;
file = new File("Science-A.txt");
try {
reader = new Scanner(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
while (reader.hasNextLine()) {
String data = reader.nextLine();
content.append(data).append("\n");
answers[2][i] = data;
i++;
}
i = 0;
file = new File("IT-A.txt");
try {
reader = new Scanner(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
while (reader.hasNextLine()) {
String data = reader.nextLine();
answers[3][i] = data;
i++;
}
i = 0;
file = new File("Imp-A.txt");
try {
reader = new Scanner(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
while (reader.hasNextLine()) {
String data = reader.nextLine();
answers[4][i] = data;
i++;
}
i = 0;
file = new File("GK-A.txt");
try {
reader = new Scanner(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
content = new StringBuilder();
while (reader.hasNextLine()) {
String data = reader.nextLine();
content.append(data).append("\n");
inanswers[0][i] = data;
i++;
}
i = 0;
file = new File("Math-A.txt");
try {
reader = new Scanner(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
while (reader.hasNextLine()) {
String data = reader.nextLine();
content.append(data).append("\n");
inanswers[1][i] = data;
i++;
}
i = 0;
file = new File("Science-A.txt");
try {
reader = new Scanner(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
while (reader.hasNextLine()) {
String data = reader.nextLine();
content.append(data).append("\n");
inanswers[2][i] = data;
i++;
}
i = 0;
file = new File("IT-A.txt");
try {
reader = new Scanner(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
while (reader.hasNextLine()) {
String data = reader.nextLine();
inanswers[3][i] = data;
i++;
}
i = 0;
file = new File("Imp-A.txt");
try {
reader = new Scanner(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
while (reader.hasNextLine()) {
String data = reader.nextLine();
inanswers[4][i] = data;
i++;
}
reader.close();
ScoreView.setText("Score: " + score);
}
public void Save() {
try {
JaScri.writeFile("Progress.data", "UTF-8", JaScri.base64("encode", "00"));
} catch (FileNotFoundException | UnsupportedEncodingException | ConversionTypeNotFound e) {
throw new RuntimeException(e);
}
}
public void startQuiz(int index) {
qi = index;
Intent intent = new Intent(QuizieMain.this, QuiziePage.class);
startActivity(intent);
setContentView(R.layout.activity_quizie_page);
}
}
Please help.
Thank you
many parts of source code are out of date, use deprecated abstract class.
Hi,
Thanks for the util. Helped me a lot. But I encounter one issue when i try to get the URI from camera intent.
Phone is Sony Experia Z, android 4.4, the camera stores the images in an external SD Card
The URI returned will be something like content://media/external/images/media/174394
Because it is 4.4, it will go to getRealPathFromURI_API19() method, but it will fail at this line
String wholeID = DocumentsContract.getDocumentId(uri);
returning a Not a document error
So what I did (which is working for me) was
public static String getRealPathFromURI_API19(Context context, Uri uri){
String filePath = "";
if (String.valueOf(uri).contains("documents")) {
String wholeID = DocumentsContract.getDocumentId(uri);
// Split at colon, use second item in the array
String id = wholeID.split(":")[1];
String[] column = { MediaStore.Images.Media.DATA };
// where id is equal to
String sel = MediaStore.Images.Media._ID + "=?";
Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
column, sel, new String[]{ id }, null);
int columnIndex = cursor.getColumnIndex(column[0]);
if (cursor.moveToFirst()) {
filePath = cursor.getString(columnIndex);
}
cursor.close();
} else {
filePath = getRealPathFromURI_API11to18(context, uri);
}
return filePath;
}
But, do you think it is a good idea? or there is a better condition to check rather than checking if uri contains the word 'documents'?
Avoid using deprecated classes and methods
When trying to clone using AndroidStudio, there was an error: Android Source Generator: Application Manifest.xml not found
Hi,
When I load the project android-actionbar-for-2.x.x into android studio, it gives me the following errors:
src/main/res/menu/main.xml:
Error:(3) No resource identifier found for attribute 'showAsAction' in package 'com.hmkcode.android'
Can you help me to fix it.
Thank you
How does he do it when moving How does the orange color change
Look this👇
https://user-images.githubusercontent.com/88975289/134436606-218ed4b6-3cd6-41cc-b344-67a6c78dff6f.mp4
a tut on stepper is required.
i am working and will push soon
We can add GIFs for every example in the readme with a little bit of explanation there
The website provided in the Readme.md is not working
I was always using these code for Sending data to web service through the app. but now after android M update, they closed HttpClient and use HttpUrlConnection.So how to send data to web service through HttpUrlConnection
many codes not work
In android studio the mainactivity.java shows error in doInBackground(String... urls).
The setName functions shows the error. i.e Method getText must be called from the UI thread, currently inferred thread is worker less... (Ctrl+F1) .
error in line : 149,150,151
please resolve the error.
Pertemuan 14
Hi,
android-gcm-client doesn't receive push notification,
is there any update for this project?
Regards
Onder
I used your mainactivity and realpathutil code. Unfortunately it is not sowing Real path in android Kitkat API 19. Pls help.
Hi, I'm Seyoung.
I want to use your code in my commercial app.
But I can'f find any terms and conditions for use, reproduction, and distribution.
I wonder if I can use the code for commercial distribution or not.
Please let me know how I can use the code for commercial distribution.
Thanks.
how to solve class,interface and enum expected error in android studio i add some codes in my project then i run it so it shows class,interface and enum expected.
Use Code Very good !
Hi,
My name is Shaun and I would like to use your code in a project I am doing for college. It is the android sqlite tutorial code.
The URL is https://github.com/hmkcode/Android/tree/master/android-sqlite
Regards,
Shaun
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.