Hi people, I am newbie , trying to learn android developing.
So i was making this app. which uses the camera client android clicks a picture and then sets it as wallpaper, as per the user's request.
But when i try to install it on my phone (Samsung Galaxy y duos ). It says application not installed. I am not able to understand why. I have also added the permissions on the Android manifest. Please do help me out. I will be attaching the xml for the camera app and its Class.
THE JAVA CLASS...
Code:
package com.example.done;
import java.io.IOException;
import java.io.InputStream;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
public class Camera extends Activity implements View.OnClickListener {
Button camera;
ImageButton done;
ImageView wallpaper;
int cameraData = 0;
Intent i;
Bitmap pic;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.photo);
intial();
camera.setOnClickListener(this);
done.setOnClickListener(this);
InputStream is = getResources().openRawResource(R.drawable.abc);
pic= BitmapFactory.decodeStream(is);
int cameraData = 0;
Intent i;
}
private void intial() {
// TODO Auto-generated method stub
camera = (Button) findViewById(R.id.camera);
done = (ImageButton) findViewById(R.id.imgTile);
wallpaper = (ImageView) findViewById(R.id.imagButt);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.camera:
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, cameraData);
break;
case R.id.imagButt:
try {
getApplicationContext().setWallpaper(pic);
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
Bundle e = i.getExtras();
pic = (Bitmap) e.get("data");
wallpaper.setImageBitmap(pic);
}
}
}[/CODE]
the Xml file (photo.xml)
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="xda wont allow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imgTile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/abc"
android:layout_gravity="center" />
<ImageButton
android:id="@+id/imagButt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_launcher" />
<Button
android:id="@+id/camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Button" />
</LinearLayout>
ThankYou in advance
Please add your manifest to the OP too, the issue is most likely in it (The first thing that comes to my mind is that your app has a higher android:minSdkVersion than your device's version of android)
Also, did you export a signed apk?
Are you using Eclipse ?
If you do, just make a right click on your project name and choose "Run As --> Android Application" to launch it on your connected device with adb enabled.
If you want to export a signed apk, right click your project's name and choose "Android tools --> Export Signed Application Package..." and follow the instructions in the daemon.
Manifest
Androguide.fr said:
Please add your manifest to the OP too, the issue is most likely in it (The first thing that comes to my mind is that your app has a higher android:minSdkVersion than your device's version of android)
Also, did you export a signed apk?
Are you using Eclipse ?
If you do, just make a right click on your project name and choose "Run As --> Android Application" to launch it on your connected device with adb enabled.
If you want to export a signed apk, right click your project's name and choose "Android tools --> Export Signed Application Package..." and follow the instructions in the daemon.
Click to expand...
Click to collapse
Yeah i am on eclipse.
And yup I am using a signed APK.
Actually, if i hit run. It would start up my emulator(It is installng on that perfectly).
But i have not connected my emulator to the webcam, so it would forceClose.
I have also set my emulator to Qvga.
And yup, the i have attached the manifest too.:good::good:
Manifest
Androguide.fr said:
Please add your manifest to the OP too, the issue is most likely in it (The first thing that comes to my mind is that your app has a higher android:minSdkVersion than your device's version of android)
Also, did you export a signed apk?
Are you using Eclipse ?
If you do, just make a right click on your project name and choose "Run As --> Android Application" to launch it on your connected device with adb enabled.
If you want to export a signed apk, right click your project's name and choose "Android tools --> Export Signed Application Package..." and follow the instructions in the daemon.
Click to expand...
Click to collapse
Yeah i am on eclipse.
And yup I am using a signed APK.
Actually, if i hit run. It would start up my emulator(It is installng on that perfectly).
But i have not connected my emulator to the webcam, so it would forceClose.
I have also set my emulator to Qvga.
And yup, the i have attached the manifest too.:good::good:
Actually the app i am developing, includes a menu which includes some other apps. Everything other app was working fine, until i added the camera app. . If you want the classes of the other apps, I can provide you that. But please help me. Thanks
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.done"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.done.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.done.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.done.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Password"
android:label="@string/app_name" >
</activity>
<activity
android:name=".Email"
android:label="@string/app_name" >
</activity>
<activity
android:name=".Camera"
android:label="cameraApp"
android:screenOrientation="portrait" >
</activity>
</application>
</manifest>
Add this permission to your manifest :
Code:
<uses-permission android:name="android.permission.CAMERA"/>
What version of Android is your device running ? You might wanna change this line
Code:
android:targetSdkVersion="8"
to :
Code:
android:targetSdkVersion="17"
if you want your app to support devices running ics & jellybean and/or be able to use the latest APIs (download the android 4.2.2 sdk platform if eclipse throws an error)
EDIT : you also have a whitespace in this line, remove it :
Code:
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CA [COLOR="DarkRed"]here [/COLOR]PTURE
It would be helpful if you paste in here the output of the console. It has nothing to do with the java code since it is being installed in the emulator.
Still not working
Androguide.fr said:
Add this permission to your manifest :
Code:
<uses-permission android:name="android.permission.CAMERA"/>
What version of Android is your device running ? You might wanna change this line
Code:
android:targetSdkVersion="8"
to :
Code:
android:targetSdkVersion="17"
if you want your app to support devices running ics & jellybean and/or be able to use the latest APIs (download the android 4.2.2 sdk platform if eclipse throws an error)
EDIT : you also have a whitespace in this line, remove it :
Code:
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CA [COLOR="DarkRed"]here [/COLOR]PTURE
Click to expand...
Click to collapse
As you said, i made all the changes. (Includind premissions etc.)
But it is not working.
When i run it on my emulator, it is getting installed. But when i run it on my phone.. It says app not installed.
Also I am attchiing the console output.
[2013-04-16 12:49:11 - Emulator] emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
[2013-04-16 12:49:12 - done] New emulator found: emulator-5554
[2013-04-16 12:49:12 - done] Waiting for HOME ('android.process.acore') to be launched...
[2013-04-16 12:50:09 - done] HOME is up on device 'emulator-5554'
[2013-04-16 12:50:09 - done] Uploading done.apk onto device 'emulator-5554'
[2013-04-16 12:50:35 - done] Installing done.apk...
[2013-04-16 12:50:57 - done] Success!
[2013-04-16 12:50:57 - done] Starting activity com.example.done.Splash on device emulator-5554
[2013-04-16 12:51:00 - done] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.done/.Splash }
hiphop12ism said:
As you said, i made all the changes. (Includind premissions etc.)
But it is not working.
When i run it on my emulator, it is getting installed. But when i run it on my phone.. It says app not installed.
Also I am attchiing the console output.
[2013-04-16 12:49:11 - Emulator] emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
[2013-04-16 12:49:12 - done] New emulator found: emulator-5554
[2013-04-16 12:49:12 - done] Waiting for HOME ('android.process.acore') to be launched...
[2013-04-16 12:50:09 - done] HOME is up on device 'emulator-5554'
[2013-04-16 12:50:09 - done] Uploading done.apk onto device 'emulator-5554'
[2013-04-16 12:50:35 - done] Installing done.apk...
[2013-04-16 12:50:57 - done] Success!
[2013-04-16 12:50:57 - done] Starting activity com.example.done.Splash on device emulator-5554
[2013-04-16 12:51:00 - done] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.done/.Splash }
Click to expand...
Click to collapse
You're giving us the output for the emulator here... We need to see the output for when you install it on an actual device as it's where your problem is.
I attached a screenshot.
I hope that helps.
So as i told you, everything was working fine. Until i added the camera app. But for experiment's sake, i deleted the app's xml, java and the activity from the manifest. But still the same result.
As i.told you, the camera app is a sub app in my phone..
The whole app contains some more app. But even then its not working:thumbup::thumbup:
Sent from my GT-S6102 using xda app-developers app
Problem Solved
Hey fellas.
I thought that changing the phone, would solve the problem,
So i used samsung s2 instead of samasing galaxy y duos.
And the app worked....
But i am not able to determine the reason.
Why don't you post the output of the console? You have been asked several times :good:
You will not find anything in the console.
As eclipse installes the apk in my emulator. In the emulator, it installs perfectly. So everything in the console is positve. Anyways i have already attached the console output in the previous page. And if you need the logcat. I will provide you.
Anyways, a great thanks for your concern
--------+---------+-----------+-------------
Sent from my GT-S6102 using xda app-developers app
Could you provide us your android manifest?
Maybe you need to set a lower minSdkVersion. (Although it says "Parsing error" on my Samsung Galaxy Ace if there is a wrong minSdkVersion)
I have copied the manifest in the previous page. I have tried putting minsdk on qvga adpi.
But it didnt work..
Sent from my GT-S6102 using xda app-developers app
hiphop12ism said:
I have copied the manifest in the previous page. I have tried putting minsdk on qvga adpi.
But it didnt work..
Sent from my GT-S6102 using xda app-developers app
Click to expand...
Click to collapse
Ah. Ok. Thanks.
The minSdkVersion is the minimum Android version which has to be installed on the device.
8 is the code for Android 2.2.
Which Android version is running on your device? Maybe you will need to set it to a lower value.
i have 2.3.6
Sent from my GT-S6102 using xda app-developers app
Hi, developers!
I have been googling and searching on stackoverflow a lot, but I still haven't found a solution to my problem:
I'm developing an Android application which uses a BroadcastReceiver to know when the phone is plugged in in order to do some work. On my Nexus 5 running Android 4.4.4 it works as expected, but a friend of mine tested it on his Samsung Galaxy S running Android 2.3.6 Gingerbread and the BroadcastReceiver doesn't work as expected (the onReceive method never gets called).
My code is as follows:
Code:
public class PowerConnectionReceiver extends WakefulBroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent serviceIntent = new Intent(context, MyService.class);
startWakefulService(context, serviceIntent);
}
}
And then I register my BroadcastReceiver in the AndroidManifest:
Code:
<receiver
android:name=".activities.PowerConnectionReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
</intent-filter>
</receiver>
Any ideas on how to make the BroadcastReceiver work?
Thanks in advance.
I tried to follow the tutorials on internet to start application start at boot time , but it does not seems to work.
i followed the tutorial, i also downloaded and installed this example source code, but this application wont work, its not showing at startup, is that something wrong with my device ? or is it has a technical changes like OS forbid it to run or something?
You need to create boot receiver:
public class BootExampleReciever extends BroadcastReceiver
{
@override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
you need to add the following permission to the manifest:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
and to declare the receiver as well:
<receiver android:name=".BootExampleReciever">
<intent-filter >
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
Well I posted it in android studio forum here but I don't know if it belongs to here..
any way -
READ ONLY EDIT DOWN!!
Okay, so I can't develop nothing as my Android Studio decided to. My all project is full of errors, unknown errors caused by Android Studio.
note: my files are correct, it is an other problem because even if I will import something from google codes it will have errors.
When I import a project everything's fine, but then after indexing and such things, all sudden everything is red and shouldn't be.
My errors for example are :
Code:
button1.setOnLongClickListener(new View.OnLongClickListener() {
....
....
}
Well shouldn't be error but :
Code:
cannot resolve symbol setOnLongClickListener
Another example:
Code:
button1=(Button) findViewById(R.id.button1);
I used this exact code for other button, seems right, I always using this line, it was fine until my Android Studio decided to give me some hard time, this line is full by errors and they are:
Code:
Unknown class: 'button1' , invalid method declaration; return type required, missing method body, or declare abstract
and there are like 20 errors that shouldn't be, things I tried:
1.deleting iml files , .idea folder - worked for a while but now it happened again and it doesn't fix it.
2.reinstalling android studio and then importing project.
3.upgrading android studio version to 1.3
4.restarting my pc.
5.importing project to an other pc, happened after a while.
6.Invalidate caches/ restart.
7.Changing module in project structure - I changed it back to how it was (it didn't help) and I think it caused the manifest error down..
My Module:app build.gradle:
Code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "firstappdevelopments.david.reactiontime"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
}
Also I noticed now, my Manifest file as an error in
Code:
android:name=".MainActivity"
says it has no default structure. something like this. here is the full normal code:
Code:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
</manifest>
Please, if someone knows what is the problem or what can I else do, just say, and I am sorry about my English, thank you all.
EDIT!!!:
I deleted this lines:
Code:
connect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
bluetooth = BluetoothAdapter.getDefaultAdapter();
if (bluetooth != null) {
if (bluetooth.isEnabled()) {
bluetooth.startDiscovery();
Set<BluetoothDevice> bondedSet = bluetooth.getBondedDevices();
if(bondedSet.size() > 0){
for(BluetoothDevice device : bondedSet){
newDevicesListView.setVisibility(View.VISIBLE);
mArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
}else{
mArrayAdapter.add("No Devices");
}
}
} else {
textview.setText("bluetooth is disabled, enabling.");
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, RESULT_OK);
}
} else{
textview.setText("Bluetooth is not supported.");
}
}
});
AND SUDDENLY ALL THE ERRORS DISSAPPEARED , ANY IDEAS? - The errors was in other lines..
I dont understand the 2nd one but i cann help u in button prblm..
try this
Button button1 = (Button)findViewById(R.id.blahblah);
and button1.setOnLongClickListenetblahblahnla.......
try and let me know
Hallo,
i want to add a new Contact in Android 6.0 but i get a permission problem and i dont now why.
This is my code:
Code:
Context cntx = getApplicationContext();
WritePhoneContact("John", "9999999999", cntx);
public void WritePhoneContact(String displayName, String number,Context cntx /*App or Activity Ctx*/)
{
Context contetx = cntx; //Application's context or Activity's context
String strDisplayName = displayName; // Name of the Person to add
String strNumber = number; //number of the person to add with the Contact
ArrayList<ContentProviderOperation> cntProOper = new ArrayList<ContentProviderOperation>();
int contactIndex = cntProOper.size();//ContactSize
//Newly Inserted contact
// A raw contact will be inserted ContactsContract.RawContacts table in contacts database.
cntProOper.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)//Step1
.withValue(RawContacts.ACCOUNT_TYPE, null)
.withValue(RawContacts.ACCOUNT_NAME, null).build());
//Display name will be inserted in ContactsContract.Data table
cntProOper.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)//Step2
.withValueBackReference(Data.RAW_CONTACT_ID,contactIndex)
.withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
.withValue(StructuredName.DISPLAY_NAME, strDisplayName) // Name of the contact
.build());
//Mobile number will be inserted in ContactsContract.Data table
cntProOper.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)//Step 3
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID,contactIndex)
.withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
.withValue(Phone.NUMBER, strNumber) // Number to be added
.withValue(Phone.TYPE, Phone.TYPE_MOBILE).build()); //Type like HOME, MOBILE etc
try
{
// We will do batch operation to insert all above data
//Contains the output of the app of a ContentProviderOperation.
//It is sure to have exactly one of uri or count set
ContentProviderResult[] contentProresult = null;
contentProresult = contetx.getContentResolver().applyBatch(ContactsContract.AUTHORITY, cntProOper); //apply above data insertion into contacts list
}
catch (RemoteException exp)
{
//logs;
}
catch (OperationApplicationException exp)
{
//logs
}
}
Permission at the Manifest
Code:
<uses-spermission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
Error Messge: Permission Denial: writing com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/raw_contacts from pid=32347, uid=10240 requires android.permission.WRITE_CONTACTS, or grantUriPermission()
Thank you for help
Uses-Spermission?
ageofempires said:
..... Error Messge: Permission Denial ....
Click to expand...
Click to collapse
I've had the same errors.
Don't know why.
Thoughts: Sync program on my PC is interfering when syncing Contacts and Agenda with Outlook.
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
I Hope it helped!