Android permission dialog not showing - java

In my app I need access to permission READ_EXTERNAL_STORAGE
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:dataExtractionRules="#xml/data_extraction_rules"
android:fullBackupContent="#xml/backup_rules"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:preserveLegacyExternalStorage="true"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.NoteApp"
tools:targetApi="31">
<activity
android:name=".activities.CreateNoteActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".activities.MainActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden"
android:exported="true"
android:label="#string/app_name"
android:theme="#style/Theme.NoteApp.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
</application>
</manifest>
In my code I check If I already have permissions, and if NOT:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_note);
ImageView imageBack = findViewById(R.id.imageBack);
imageBack.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
onBackPressed();
}
});
inputNoteTitle = findViewById(R.id.inputNoteTitle);
inputNoteText = findViewById(R.id.inputNote);
textDateTime = findViewById(R.id.textDateTime);
imageNote = findViewById(R.id.imageNote);
textDateTime.setText(
new SimpleDateFormat("EEEE, dd MMMM yyyy HH:mm a", Locale.getDefault())
.format(new Date())
);
ImageView imageSave = findViewById(R.id.imageSave);
imageSave.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
saveNote();
}
});
ImageView imageAddImage = findViewById(R.id.imageAddImage);
imageAddImage.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
int requestPermission = ContextCompat.checkSelfPermission(
getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE
);
if (requestPermission != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(
CreateNoteActivity.this,
new String[] {Manifest.permission.READ_EXTERNAL_STORAGE},
REQUEST_CODE_STORAGE_PERMISSION
);
}
else {
selectImage();
}
}
});
}
#Override
public void onRequestPermissionsResult(int requestCode, #NonNull String[] permissions, #NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_CODE_STORAGE_PERMISSION && grantResults.length > 0){
Log.d("DEBUG", "" + grantResults[0]);
if (grantResults[0] == PackageManager.PERMISSION_GRANTED){
selectImage();
}
else {
Toast.makeText(this, "Permission Denied!", Toast.LENGTH_SHORT).show();
}
}
}
But the permissions dialog never shows, let alone is onRequestPermissionsResult() called.
I don't know why the dialog doesn't show when i use READ_EXTERNAL_STORAGE but it work with READ_MEDIA_IMAGES.

Related

Android Permission ACCESS_FINE_LOCATION is always denied

I try to check the permission on button click and it always gives me -1
Here is my AndroidManifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.natalia.assignment_2">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Also i have compileSdkVersion 28, minSdkVersion 22 and targetSdkVersion 28.
In my MainActivity, I try to check the permissions and it always denied, because it returns -1
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button buttonLocate = (Button) findViewById(R.id.buttonLocate);
buttonLocate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
askForPermission("android.permission.ACCESS_FINE_LOCATION");
});
}
private void askForPermission(String permission) {
if(MainActivity.this != null) {
if (PermissionChecker.checkSelfPermission(MainActivity.this, permission) != PackageManager.PERMISSION_GRANTED) {
// IT ALWAYS COMES TO THIS IF AND SHOWS -1
Toast.makeText(this, "" + String.valueOf(PermissionChecker.checkSelfPermission(MainActivity.this, permission)), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "" + permission + " is already granted.", Toast.LENGTH_SHORT).show();
}
}
}
}
I tried many hours, but nothing helps...what could be a problem here?
askForPermission("android.permission.ACCESS_FINE_LOCATION");
This is what you had when passing into your method.
Try doing :
askForPermission("Manifest.permission.ACCESS_FINE_LOCATION");
This may work. If not, I checked some other articles and everywhere I looked, it wasn't passed in as a String.
Try using this without a String:
(PermissionChecker.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)
Hope it works!

Android Wear not receiving OnDataChanged call

I have read any thread that is on this topic in the last 2 days.. but I still cannot figure out what is wrong with my code.
I have Mobile and Wear app. the mobile has only widget and widgetconfig activities (no main activity).
Here is the mobile app files:
AndroidManifest: (simple appwidget and appwidget_config activities)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.xx.yy.remotedoor">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE"/>
<application
android:allowBackup="true"
android:icon="#drawable/housek"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".DoorConf"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
<receiver android:name=".upDoor">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/up_door_info" />
</receiver>
</application>
</manifest>
upDoor.java: (Look at send_to_wear function)
package net.xx.yy.remotedoor;
import ...
public class upDoor extends AppWidgetProvider {
public static String TAG = "Remote door GAPI";
public static String CLICK_DOOR = "ClickDoorOpen";
public static String DOOR_ID = "DoorID";
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
CharSequence widgetText = "Test";
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.up_door_widget);
views.setTextViewText(R.id.textView, widgetText);
Intent intent = new Intent(context, upDoor.class);
intent.setAction(CLICK_DOOR);
intent.putExtra(DOOR_ID, Integer.toString(appWidgetId));
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.houseIcon, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetId, views);
send_to_wear(context);
}
}
private static void send_to_wear(Context context) {
// Sending data to wear
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(context)
.addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
#Override
public void onConnected(Bundle connectionHint) {
Log.d(TAG, "onConnected: " + connectionHint);
}
#Override
public void onConnectionSuspended(int cause) {
Log.d(TAG, "onConnectionSuspended: " + cause);
}
})
.addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
#Override
public void onConnectionFailed(ConnectionResult result) {
Log.d(TAG, "onConnectionFailed: " + result);
}
})
.addApi(Wearable.API)
.build();
Log.w("Google API", "Connecting");
mGoogleApiClient.connect();
Log.w("Google API", Boolean.toString(mGoogleApiClient.isConnected()));
PutDataMapRequest putDataMapReq = PutDataMapRequest.create("/doors/1");
putDataMapReq.getDataMap().putString("caption", "test"); putDataMapReq.getDataMap().putLong("Time",System.currentTimeMillis());
putDataMapReq.setUrgent();
PutDataRequest putDataReq = putDataMapReq.asPutDataRequest();
com.google.android.gms.common.api.ResultCallback<DataApi.DataItemResult> send_callback =
new ResultCallback<DataApi.DataItemResult>() {
#Override
public void onResult(#NonNull DataApi.DataItemResult result) {
if (!result.getStatus().isSuccess()) {
Log.w("Result", "Failed");
}else{
Log.w("Result", "Success");
}
Log.w("Item", result.getDataItem().getUri().toString());
Log.w("Reason", result.getStatus().getStatusMessage());
}
};
com.google.android.gms.common.api.PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi.putDataItem(mGoogleApiClient, putDataReq);
pendingResult.setResultCallback(send_callback);
}
#Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
for (int appWidgetId : appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId);
}
}
#Override
public void onEnabled(Context context) {...}
#Override
public void onDisabled(Context context) {...}
#Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
if (intent.getAction().equals(CLICK_DOOR)) {
send_to_wear(context);
}
}
}
On the Wear side:
Manifest: (I configured it at same package name, is that ok?)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.xx.yy.remotedoor">
<uses-feature android:name="android.hardware.type.watch" />
<application
android:allowBackup="true"
android:icon="#drawable/housek"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#android:style/Theme.DeviceDefault">
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<activity
android:name=".main"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".dataLayer" android:exported="false" android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.wearable.DATA_CHANGED" />
<action android:name="com.google.android.gms.wearable.MESSAGE_RECEIVED" />
<data android:scheme="wear" android:host="*" android:pathPrefix="*" />
</intent-filter>
</service>
</application>
</manifest>
and the dataLayer java part:
package net.xx.yy.remotedoor;
import ...
public class dataLayer extends WearableListenerService { //implements DataApi.DataListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
private static final String TAG = "LOG";
#Override
public void onDataChanged(DataEventBuffer dataEvents) {
Log.w(TAG, "Wear got on_change");
final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.build();
// Do I need it??
ConnectionResult connectionResult = googleApiClient.blockingConnect(30, TimeUnit.SECONDS);
if (!connectionResult.isSuccess()) {
Log.e(TAG, "Failed to connect to GoogleApiClient.");
return;
}
for (DataEvent dataEvent : events) {
if (dataEvent.getType() == DataEvent.TYPE_CHANGED) {
DataItem item = dataEvent.getDataItem();
Log.w(TAG, "item path: " + item.getUri().getPath());
if(item.getUri().getPath().startsWith("/doors/")){
DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
// Do something
}
}
}
}
}
On the mobile log I can see:
DataItemResult : Success
Item: wear://HOST_ID/doors/1
On the wear log I cannot see anything related to this..
What am I doing wrong!?
Thanks!!

Android fatal exception unable to resume activity

Hi everybodi!
I'm new to Android programming and am trying to create a QR code reader app with Zxing. When I start my application in my phone, it gives me this error message. The app is started, after I push the button and then this is thrown... What is the problem?
Here is my code: This is the MainActivity
package com.example;
public class MainActivity extends Activity {
private Button scan;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
scan= (Button)findViewById(R.id.button1);
scan.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
}
});
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
// Handle successful scan
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
Log.i("App","Scan unsuccessful");
}
}
}
#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;
}
}
And this is my AndoridManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.CAMERA"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:noHistory = "true"
android:name="com.example.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>
<activity
android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="com.google.zxing.client.android.SCAN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>

how do I get value from BroadcastReceiver activity to main activity

I want get the install referrer value in my MainActivity. For that i am using two class
1) MainActivity
2) ReferrerReceiver
I got received install referrer value successfully in ReferrerReceiver class, i tested this using Toast control.
But i can not able to pass this value to MainActivity from ReferrerReceiver.
Bellow is i tried code. please any one help me.
Thanks for advance.
1) MainActivity.java
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv1 = (TextView) findViewById(R.id.tv1);
Intent in1= getIntent();
String ldString = in1.getStringExtra("number");
tv1.setText(ldString);
}
}
2) ReferrerReceiver.java
public class ReferrerReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
if (!intent.getAction().equals("com.android.vending.INSTALL_REFERRER")) {
return;
}
Bundle bundle = intent.getExtras();
String phoneNumber = bundle.getString("referrer");
Intent i = new Intent(context, MainActivity.class);
i.putExtra("number", phoneNumber);
context.startActivity(i);
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myreferrer.in"
android:versionCode="7"
android:versionName="1.0.6" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<receiver android:name="com.myreferrer.in.ReferrerReceiver"
android:enabled="true">
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:launchMode="singleTask"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This was i implemented in my project. its working for me. Use this code
(1) MainActivity.java
public class MainActivity extends Activity {
TextView tv1;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv1 = (TextView) findViewById(R.id.tv1);
}
public static void log(Context context, String string) {
if(string!=null) {
Toast.makeText(conte, "Referrer value is."+string, Toast.LENGTH_LONG).show();
tv1.setText(string);
}
}
(2) ReferrerReceiver.java
public class ReferrerReceiver extends BroadcastReceiver {
String referrer,rawReferrer;
public static String getReferrer(Context context) {
// Return any persisted referrer value or null if we don't have a referrer.
return context.getSharedPreferences("referrer", Context.MODE_PRIVATE).getString("referrer", null);
}
#Override
public void onReceive(Context context, Intent intent) {
try {
// Make sure this is the intent we expect - it always should be.
if ((null != intent) && (intent.getAction().equals("com.android.vending.INSTALL_REFERRER"))) {
// This intent should have a referrer string attached to it.
rawReferrer = intent.getStringExtra("referrer");
if (null != rawReferrer) {
// The string is usually URL Encoded, so we need to decode it.
referrer = URLDecoder.decode(rawReferrer, "UTF-8");
Toast.makeText(context, "ReferrerReceiver." + referrer, Toast.LENGTH_LONG).show();
MainActivity.log(context,"\nRaw referrer: " + rawReferrer +"\nReferrer: " + referrer);
MainActivity.log(context,referrer);
// Persist the referrer string.
context.getSharedPreferences("referrer", Context.MODE_PRIVATE).
edit().putString("referrer", referrer).commit();
} else {
Toast.makeText(context, "ReferrerReceiver." + referrer, Toast.LENGTH_LONG).show();
MainActivity.log(context,referrer);
context.getSharedPreferences("referrer", Context.MODE_PRIVATE).
edit().putString("referrer", referrer).commit();
}
} else {
Toast.makeText(context, "ReferrerReceiver intent value is null.", Toast.LENGTH_LONG).show();
MainActivity.log(context,referrer);
MainActivity.log(context,"intent value is nulll");
context.getSharedPreferences("referrer", Context.MODE_PRIVATE).
edit().putString("referrer", "intent value is nulll").commit();
}
}
catch (Exception e) {
//Toast.makeText(context, "ReferrerReceiver catch"+e, Toast.LENGTH_LONG).show();
MainActivity.log(context, e.toString());
}
}
}
(3) AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myreferrer.in"
android:versionCode="7"
android:versionName="1.0.6" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<receiver android:name="com.myreferrer.ReferrerReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER"></action>
</intent-filter>
</receiver>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:launchMode="singleTask"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
(4) sample link:
https://play.google.com/store/apps/details?id=your_package_name&referrer=Welcome
You are using
Intent in1 = new Intent();
String ldString = in1.getStringExtra("KEY");
you are declaring new intent which is wrong, and also key you put is also wrong, which should be number
Replace it With,
Intent intent= getIntent();
String ldString = intent.getStringExtra("number");
you have declared your activity as"single Task" in Manifest;so if an instance of your
activity is already launched the system will create (NewIntent) to re_lunch your
activity.try to put this code before onCreate():
#Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// NOW getIntent() should always return the recent
setIntent(intent);
}
to get all the time the newest intent with the new extras.

Try to resolve ActivityNotFoundException

I try to share a post on google+ but I obtain this Exception. The Activity that creates the Exception is ExampleActivity and this is its code:
public class ExampleActivity extends Activity implements OnClickListener,
ConnectionCallbacks, OnConnectionFailedListener {
private static final String TAG = "ExampleActivity";
private static final int REQUEST_CODE_RESOLVE_ERR = 9000;
private ProgressDialog mConnectionProgressDialog;
private PlusClient mPlusClient;
private ConnectionResult mConnectionResult;
#Override//onCreate
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_example);
mPlusClient = new PlusClient.Builder(this, this, this)
.setVisibleActivities("http://schemas.google.com/AddActivity","http://schemas.google.com/BuyActivity")
.build();
// Progress bar to be displayed if the connection failure is not resolved.
mConnectionProgressDialog = new ProgressDialog(this);
mConnectionProgressDialog.setMessage("Signing in...");
Button shareButton = (Button) findViewById(R.id.share_button);
shareButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// Launch the Google+ share dialog with attribution to your app.
Intent shareIntent = new PlusShare.Builder()
.setType("text/plain")
.setText("Welcome to
the Google+ platform.")
.setContentUrl(Uri.parse("https://developers.google.com/+/"))
.getIntent();
startActivityForResult(shareIntent, 0);
}
});
}
#Override//onStart
protected void onStart() {
super.onStart();
mPlusClient.connect();
}
#Override//onStop
protected void onStop() {
super.onStop();
mPlusClient.disconnect();
}
#Override// onConnectionFailed
public void onConnectionFailed(ConnectionResult result) {
if (mConnectionProgressDialog.isShowing()) {
// The user clicked the sign-in button already. Start to resolve
// connection errors. Wait until onConnected() to dismiss the
// connection dialog.
if (result.hasResolution()) {
try {
result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
} catch (SendIntentException e) {
mPlusClient.connect();
}
}
}
// Save the result and resolve the connection failure upon a user click.
mConnectionResult = result;
}
#Override //onActivityResult
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
if (requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) {
mConnectionResult = null;
mPlusClient.connect();
}
}
// #Override
// public void onConnected(Bundle connectionHint) {
// String accountName = mPlusClient.getAccountName();
// Toast.makeText(this, accountName + " is connected.", Toast.LENGTH_LONG).show();
// }
#Override //onDisconnected
public void onDisconnected() {
String accountName = mPlusClient.getAccountName();
Toast.makeText(this, accountName + " is connected.", Toast.LENGTH_LONG).show();
}
#Override//onConnected
public void onConnected() {
// TODO Auto-generated method stub
}
#Override
public void onClick(View arg0) {
}
}
This is the AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.applicazionescienza"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.applicazionescienza.Menu"
android:label="#string/app_name"
android:launchMode="singleInstance" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.applicazionescienza.Informazioni"
android:label="#string/title_activity_informazioni" >
</activity>
<activity
android:name="com.example.applicazionescienza.Regolamento"
android:label="#string/title_activity_regolamento" >
</activity>
<activity
android:name="com.example.applicazionescienza.Gioca"
android:label="#string/title_activity_gioca" >
</activity>
<activity
android:name="com.example.applicazionescienza.Livello"
android:label="#string/title_activity_livello" >
</activity>
<activity
android:name="com.example.applicazionescienza.Punteggio"
android:label="#string/title_activity_punteggio" >
</activity>
<activity
android:name="com.example.applicazionescienza.TwitterActivity"
android:label="#string/title_activity_twitter"
android:launchMode="singleInstance" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="casa"
android:scheme="app" />
</intent-filter>
</activity>
<activity
android:name="com.example.applicazionescienza.FacebookActivity"
android:label="#string/title_activity_facebook" >
</activity>
<activity
android:name="com.example.applicazionescienza.ExampleActivity"
android:label="#string/title_activity_example" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
The Exception say: No activity found to handle Intent(act=android.intent.action.SEND....
Someone can help me?
Try and clean the project, uninstall your app from device and reinstall.

Categories