Launch Intent from account-authenticator accountPreferences screen? - settings

I have included the AccountManager code in my app to enable the user to create and manage their account from inside their Settings application.
I linked in the "accountPreferences" preferences file inside my account-authenticator definition, and the options show properly in the Settings > Accounts > My App screen. When I tap on one of them, instead of getting the activity I linked in, I get:
01-14 14:47:27.304: ERROR/AndroidRuntime(27708): FATAL EXCEPTION: main
android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
at android.app.ContextImpl.startActivity(ContextImpl.java:944)
at android.app.ContextImpl.startActivity(ContextImpl.java:931)
at android.preference.Preference.performClick(Preference.java:967)
at android.preference.PreferenceScreen.onItemClick(PreferenceScreen.java:215)
I have the intents inside my PreferenceScreen defined as:
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.myapp.android"
android:targetClass="com.myapp.android.activities.AccountForwardingActivity"/>
And the target activity is also defined as you'd expect, with no special flags other than an intent-filter to match that action (I have other custom actions listed as well).
<activity android:name=".activities.AccountForwardingActivity"
android:theme="#style/Theme.MyApp"
android:launchMode="singleTask">
<intent-filter>
<action android:name="com.myapp.android.PAYMENT_TYPES"/>
<action android:name="com.myapp.android.ADDRESS_LIST"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
What am I doing wrong? How can I mark this intent, launched from Settings.apk, to be a new task?

My problem was putting the Preference Screens inside my PreferenceCategory.
This works fine:
<PreferenceCategory android:title="General Settings" />
<PreferenceScreen
android:title="Account Settings"
android:summary="Favorites, Orders, and more.">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.myapp.android"
android:targetClass="com.myapp.android.activities.AccountForwardingActivity"/>
</PreferenceScreen>
Nesting that PreferenceScreen inside the PreferenceCategory does not work, and results in the error above.

Related

Intercom not working on android 12 Xamarin forms

io.intercom.android.sdk.fcm.IntercomFcmMessengerService: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]
I know I have to add something in the manifest similar to this but still not finding it
<receiver android:name="" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</receiver>
In Android 11 and lower, when declaring an Activity, Service, or Broadcast receiver in AndroidManifest, you did not explicitly declare android:exported. Since the default value is exported=true, you only need to declare exported=false when you do not want to disclose to the outside.
For example:
<activity android:name="com.example.app.backgroundService">
<intent-filter>
<action android:name="com.example.app.START_BACKGROUND" />
</intent-filter>
</activity>
Android 12 Changes: Explicit declaration of exported Apps that set SDK API 31 (android 12) as Target sdk on Android 12 devices must explicitly declare exported in components such as Activity that declared intent-filter.
For example,you must explicitly declare exported as follows:
<service android:name="com.example.app.backgroundService"
android:exported="false">
<intent-filter>
<action android:name="com.example.app.START_BACKGROUND" />
</intent-filter>
</service>
In a word, android:exported="true" or "android:exported="false" must be added to all receivers, services, and activity tags with intent-filters inside them.
Note:
You can find the AndroidManifest.xml in folder obj of your app. My Folder is MyAndroidProject\obj\Debug\120\.
After finding file AndroidManifest.xml, you can recheck if you have added tag android:exported to all of your receivers, services, and activity.

Unable to create an audience on Parse

I am trying to get my android app setup to send push notifications via Parse.
build.gradle
compile 'com.parse:parse-android:1.13.0'
Application.java
//in onCreate
Parse.initialize(this, "appId", "clientKey");
ParseInstallation.getCurrentInstallation().saveInBackground();
AndroidManifest.xml
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="MY_APP_ID" />
</intent-filter>
</receiver>
After booting up my app with these changes, I can see an installation object being created on the Parse dashboard.
Now when I try to send a push via the dashboard and create an audience with platform Android, it says 'Your recipient count for this campaign can’t be empty.'
What am I missing?
EDIT 1: I am able to send a push via the REST api. Still not able to send push via the web console.
I had submitted this issue to the Facebook Developers page. This is the response that I received from the Facebook Engineering Team:
This is a known issue with small recipient counts in the new dashboard. Unfortunately the engineering team doesn't plan to solve this bug in the new dashboard. Please use the old dashboard to send these push notifications.

Parse - Installation table not setting deviceToken nor pushType

I had an app working on Parse, with the notifications working fine. I changed app packaging and I create a new app on Parse.
With the new app, deviceToken and pushType columns remain always empty on table _Installation, so pushes doesn't work even if sent from Parse web page, and a new entry is generated as application is launched.
I've updated parse keys on my java code and on my cloud code.
Someone has some idea what I may have missed or what may happen so the same code has different behaviour in different apps with equivalent configurations?
If I update one of the installation with pushType="gcm" and "deviceToken" the one I had in the other app, this device receives notifications.
Thank you
okay, I had a similar issue. both those columns were empty.
this is mainly due to the manifest issue.
your permissions seem okay because you are getting the notification and also able to reg in the parse data base.
so the problem should be in the <receiver> tags there should only be 2 of them like mine.
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<!--
IMPORTANT: If you change the package name of this sample app,
change "com.parse.tutorials.pushnotifications" in the lines
below to match the new package name.
-->
<category android:name="com.example.ifis" />
</intent-filter>
</receiver>
if you have any receiver like "com.google.android.gcm.GCMBroadcastReceiver" pls remove and also one <service android:name="com.parse.PushService" />
Enable parse logging:
Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
In my case I was missing GCM permissions
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="my.package.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="my.package.permission.C2D_MESSAGE" />

Rhomobile: Custom URL Schemes

I'm writing a Rhomobile application targeted at iPhone and Android.
I need to create a custom url scheme, so that i can create urls that look like test://some-params that will launch my program and will pass it the params.
As far as I understand this is done in build.yml through the BundleURLScheme parameter, and then System.get_start_params() to get those parameters.
However, this works on the iPhone only as far as I understand.
Is there any way to make this work on Android too?
Thanks alot!
OKay, I've found the answer myself, in case anybody needs this too:
Create an extension to the application as explained here:
http://docs.rhomobile.com/rhodes/extensions#generating-a-native-extension-template
Add an android_manifest_changes file, as decribed in the above link.
In that file add the following lines:
<manifest xmlns:android='http://schemas.android.com/apk/res/android'
android:versionName='1.0' package='com.rhomobile.webbrowserpoc'
android:versionCode='10000' android:installLocation='auto'>
<application android:name='com.rhomobile.rhodes.RhodesApplication'
android:label='#string/app_name' android:icon='#drawable/icon'
android:debuggable='true'>
<activity android:name='com.rhomobile.rhodes.RhodesActivity'
android:label='#string/app_name' android:launchMode='singleTask'
android:configChanges='orientation|keyboardHidden'
android:screenOrientation='unspecified'>
<intent-filter>
<action android:name='android.intent.action.VIEW' />
<category android:name='android.intent.category.BROWSABLE' />
<category android:name='android.intent.category.DEFAULT' />
<data android:pathPrefix='' android:scheme=''
android:host='' />
</intent-filter>
</activity>
</application>
Only the <data android:pathPrefix='' android:scheme='' android:host='' /> line should be filled in with correct properties.

How does it happen Azure web role entry point and .aspx page handler are run in different processes?

I'm playing with this Azure web role sample. It contains a class derived from RoleEntryPoint and a .aspx page that contains a button click handler.
I test it in Azure Emulator. I put the following code (taken from here)
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
in both role OnStart() and the button click handler. When role OnStart() is invoked it happens to run in WaIISHost.exe under MachineName\\MyLogin account and when button handler code is invoked it happens to run in w3wp.exe under MachineName\\NETWORK SERVICE account. That's surprising.
Why are these pieces of code from the same role project run inside different processes and under different accounts? Can I change that?
David is correct. In addition to that, you can turn off this behavior and run everything in the hostable web core (as it worked before SDK 1.4). You just need to comment out the "Sites" section in the services definition like in the example below:
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="aExpense.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="aExpense" vmsize="Medium">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="HttpsIn" endpointName="HttpsIn" />
</Bindings>
</Site>
</Sites>
<ConfigurationSettings>
<Setting name="DiagnosticsConnectionString" />
<Setting name="DataConnectionString" />
<Setting name="allowInsecureRemoteEndpoints" />
</ConfigurationSettings>
With Windows Azure v1.3 and beyond, a Web Role takes advantage of the full IIS, rather than Hosted Web Core. IIS runs in a separate appdomain.
See this blog post from the Windows Azure team for the gory details.

Resources