Reputation: 37
I use the latest Xamarin and Visual Studio 2017. I have a test activity "Sample" that I want to run from the preference. I tried in different ways and still nothing. Any ideas?
Sample class to run:
namespace TestApp
{
[Activity(Label = "Sample", Name = "pl.test.TestApp.Sample")]
[IntentFilter(new[] { Intent.ActionView })]
public class Sample : Android.Preferences.PreferenceActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.login);
}
}
}
Using this I try run Sample activity:
<SwitchPreferenceCompat
android:key="pref_pow"
android:title="Pow pow"
android:summary="Pow summary" />
<PreferenceScreen
android:key="rename"
android:title="test"
android:persistent="false"
android:summary="test test test">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="pl.test.TestApp"
android:targetClass="Sample"/>
</PreferenceScreen>
I'm getting an error:
Android.Content.ActivityNotFoundException: Unable to find explicit activity class {pl.test.testapp/Sample}; have you declared this activity in your AndroidManifest.xml?
But in Xamarin I shouldn't edit AndroidManifest.xml
Upvotes: 0
Views: 519
Reputation: 74144
The targetClass
should be the fully qualified class name and since you are using the ActivityAttribute
with a param of Name = "pl.test.TestApp.Sample"
, then your intent should be:
~~~
android:targetPackage="pl.test.TestApp"
android:targetClass="pl.test.TestApp.Sample"/>
~~~
Upvotes: 1