Answer the question
In order to leave comments, you need to log in
How to get MainActivity for Intent created in another Xamarin.Droid class of the project?
I want to set an alarm for a Xamarin.Droid project. To do this, I use DependencyService to define platform-specific functions. I define an interface with a function signature
namespace ExampleProgram.Droid
{
public interface IRunAlarm
{
Intent setIntent();
...
}
}
[assembly: Dependency(typeof(ExampleProgram.Droid.RunAlarm))]
namespace ExampleProgram.Droid
{
public class RunAlarm: MainActivity, IRunAlarm
{
public Intent setIntent()
{
Intent i = new Intent(this, typeof(AlarmReceiver));
return i;
}
...
}
}
Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
Intent i = new Intent(this, typeof(AlarmReceiver));
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="3" android:versionName="3" package="com.example.exampleprogram">
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application android:label="exampleprogram" android:icon="@drawable/appicon"></application>
</manifest>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question