I have simple application created by Android studio wizard.
Here is the class of the only Activity created by Android studio wizard
package test.com.myapplication;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
System.out.println("========> PRINT");
Log.d("=====>", "PRINT");
Log.i("=====>", "PRINT");
Log.e("=====>", "PRINT");
Log.v("=====>", "PRINT");
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Application is running successfully on Note II.
Log level "verbose"
No filters.
Issue: can't see prints visible for filter "===>" or "PRINT".
"Enable ADB integration" does not change the described.
Studio version 1.2.1.1 running on mac os x.
UPDATE:
adb start-server
* daemon not running. starting it now on port 5037 *
cannot bind 'tcp:5037'
ADB server didn't ACK
* failed to start daemon *
Sometimes ADB Logcat stops working, and clicking on "Restart" in "Android" tab will force it to work again
Also sometimes just restarting your mobile device will help, or the computer you are using
I re-install the app until it works (max 3 times).
Related
I'm having issues with my prototype application. It works fine between two emulators on my PC, but when I install it on my phone it won't send text messages or even care to ask for the permission (if that is the issue).
Furthermore, I'm recieving the same error no matter what I do, on app start, each time I press a button and on every new intent start:
E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:13140)
at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2038)
at com.android.providers.settings.SettingsProvider.callFromPackage(SettingsProvider.java:607)
at android.content.ContentProvider$Transport.call(ContentProvider.java:279)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:273)
at android.os.Binder.execTransact(Binder.java:388)
at dalvik.system.NativeStart.run(Native Method)
I've been looking at a lot of similar issues, and I did add
uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" android:protectionLevel="signature"/>
to my manifest, but nothing seems to work for me.
The real odd thing to me is that the error occurs on application start, because nothing interesting really seems like nothing interesting is happening at that point:
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
// Go to contact list
public void onClick(View view) {
Intent i = new Intent(this,AddContact.class);
startActivity(i);
}
public void onGPS(View view) {
Intent j = new Intent(this,GPSActivity.class);
startActivity(j);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
Any ideas ?
The issue is seemingly with Samsung Galaxy S3. The link: Permission Denial: this requires android.permission.INTERACT_ACROSS_USERS_FULL
Provided by Sumighosh Chaurvil explains the problem; And that there's really not much to do about it.
I installed the application on another phone, and it works with no problems whatsoever!
I want to send a BLE advertisement using Android beacon library. Below is the code I am using for it.
package com.example.beacon_emitter;
import java.util.Arrays;
import org.altbeacon.beacon.Beacon;
import org.altbeacon.beacon.BeaconParser;
import org.altbeacon.beacon.BeaconTransmitter;
import android.support.v7.app.ActionBarActivity;
import android.app.Activity;
import android.bluetooth.le.AdvertiseCallback;
import android.bluetooth.le.AdvertiseSettings;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Beacon beacon = new Beacon.Builder()
.setId1("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")
.setId2("1")
.setId3("2")
.setManufacturer(0x0118)
.setTxPower(-59)
.setDataFields(Arrays.asList(new Long[] {0l}))
.build();
BeaconParser beaconParser = new BeaconParser()
.setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25");
BeaconTransmitter beaconTransmitter = new BeaconTransmitter(getApplicationContext(), beaconParser);
beaconTransmitter.startAdvertising(beacon,new AdvertiseCallback() {
#Override
public void onStartFailure(int errorCode) {
Log.e("beacon", "Advertisement start failed with code: "+errorCode);
}
#Override
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
Log.i("beacon", "Advertisement start succeeded.");
}
});
int result = BeaconTransmitter.checkTransmissionSupported(getApplicationContext());
Toast.makeText(this, "Device info " + result, Toast.LENGTH_LONG).show();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
It always gives me an errorcode 2, ADVERTISE_FAILED_TOO_MANY_ADVERTISERS. But the strange thing is when I checked the toast message it says the my device is supported the beacon transmission. I am confused.
Please help!
Thanks in Advance.
A few tips:
The BeaconTransmitter.checkTransmissionSupported() method only checks to see if the device has Bluetooth LE and that the operating system will give you a BluetoothAdvertiser.
To see if somebody else has been successful with getting your device to transmit, check to see if it is on this list: http://altbeacon.github.io/android-beacon-library/beacon-transmitter-devices.html
The ADVERTISE_FAILED_TOO_MANY_ADVERTISERS response can indicate that another app is advertising a beacon, and all the advertisement slots are used. Make sure that you don't have any other apps advertising in the background. Reboot or uninstall other apps that might be doing this if necessary.
Try the Locate Beacon app which is based on this same library, and see if it can advertise a beacon successfully. This will eliminate any possible problem with your code.
EDIT: Based on the comments below, it is reasonable to conclude that the firmware for the Intrynsyc eval kit does not properly implement the interface between Android and the Bluetooth chip. Otherwise it would either report that advertising is not available or it would not return an error message when starting advertising. The appropriate next step would be to open an issue with Intrynsyc and report these findings.
The ability to transmit as a beacon requires Bluetooth LE
advertisement capability, which may or may not be supported by a
device’s firmware.
Quote from Device Support For Beacon Transmission with Android 5+
I follow code at page: http://socket.io/blog/native-socket-io-and-android/
and download, run successfully project https://github.com/nkzawa/socket.io-android-chat.
And I want to connect socket io with my node server
Code at: server nodejs version of socket io "version": "1.3.5",
var socketIO = require('socket.io'),
http = require('http'),
port = process.env.PORT || 8080,
ip = process.env.IP || '192.168.0.105', //My IP address. I try to "127.0.0.1" but it the same => don't run
server = http.createServer().listen(port, ip, function() {
console.log("IP = " , ip);
console.log("start socket successfully");
});
io = socketIO.listen(server);
//io.set('match origin protocol', true);
io.set('origins', ':');
var run = function(socket){
socket.on("message", function(value) {
console.log(value);
});
socket.on("user-join", function(value) {
console.log(value + "user-join");
socket.broadcast.emit("new-users", value);
});
}
io.sockets.on('connection', run);
Code at Android:
package com.example.phamhuu.chatnodejs;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import com.github.nkzawa.socketio.client.IO;
import com.github.nkzawa.socketio.client.Socket;
import java.net.URISyntaxException;
public class MainActivity extends ActionBarActivity {
private Socket mSocket;
{
try {
IO.Options options = new IO.Options();
options.port = 8080;
mSocket = IO.socket("http://192.168.0.105:8080");
//mSocket = IO.socket("http://chat.socket.io");
} catch (URISyntaxException e) {
Log.e("abc", "index=" + e);
}
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mSocket.connect();
Log.e("result socket connect", String.valueOf(mSocket.connected()));
mSocket.emit("message", "Send message to server.");
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
I make sure add 'android.permission.INTERNET'
I try it on real device (My PC and my device the same wifi )but socket can't connect to server at address: 192.168.0.105 port: 8080
Can you help me?
Thanks very much.
Not really an answer to the question, but if you want to create a chat with Node.JS which works for also android clients, you can take a look at the alternative: JXM (on github) - messaging backend for JXcore (open sourced fork of Node.JS).
The problem you describe here probably will not be relevant any more.
There are practically ready samples to be used as they are (server part; clients: browsers, android, node).
I've wrote my few cents on this subject here: Simple Node.js chat program NOT using socket.io
I am trying to implement an android simple code that uses proximityalerts and gives an alert when entering and exiting some defined area
the code runs without errors but i would like to test if it works with coordinates (first not in the area, then goes in should receive an alert, then exits and receive another alert) so i googled how to use telnet to give lat,long but all i found is giving fixed values
is there another way to approach this?
PS: I am using android studio :)
EDIT: i figured out how to change the coordinates and i followed a tutorial to get proximity test ... the code runs without any errors but the intent to give the alert does not seem to fire
here is my code:
MainActivity
public class MainActivity extends ActionBarActivity {
LocationManager lm;
double lat=32.001271,long1=35.950375; //Defining Latitude & Longitude
float radius=100; //Defining Radius
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lm=(LocationManager) getSystemService(LOCATION_SERVICE);
Intent i= new Intent("com.example.hala.proximityalert"); //Custom Action
PendingIntent pi = PendingIntent.getBroadcast(getApplicationContext(), -1, i, 0);
lm.addProximityAlert(lat, long1, radius, -1, pi);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
ProximityReceiver
public class ProximityReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
// The reciever gets the Context & the Intent that fired the broadcast as arg0 & agr1
String k=LocationManager.KEY_PROXIMITY_ENTERING;
// Key for determining whether user is leaving or entering
boolean state=arg1.getBooleanExtra(k, false);
//Gives whether the user is entering or leaving in boolean form
if(state){
// Call the Notification Service or anything else that you would like to do here
Toast.makeText(arg0, "Welcome to my Area", Toast.LENGTH_LONG).show();
}else{
//Other custom Notification
Toast.makeText(arg0, "Thank you for visiting my Area,come back again !!", Toast.LENGTH_LONG).show();
}
}
}
so if anyone has an idea on why it doesn't fire i would really appreciate the help
You can give coordinates via :
Eclipse -> DDMS -> Emulator Control tab -> Give coordinate includes
latitude and longitude
My goal is to support a functionality that mute phone (possibly with vibrations enabled/disabled), so when a call or sms is received it won't make noise
unmute phone but prompt for "password for unmute".
And this remains valid for any other application, that it ask for password entry before unmute...
How can I do this? What permissions are required in AndroidManifest?
Previously on Stackoverflow, Android mute/unmute phone.
Those answers discuss both permissions and the coding. Also, tasker can handle everything you're looking to do.
And here's a link to a tutorial.
The code below runs fine in the emulator. When you run it, you can see the mute goes on in the notification area. In addition to the code, I had to add the (uses) permission for android.permission.MODIFY_AUDIO_SETTINGS.
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
AudioManager audio = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
audio.setRingerMode(AudioManager.RINGER_MODE_SILENT);
return true;
}