Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Fix crash on Android 12 #245

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Facebook.Android/build.cake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#addin nuget:?package=Cake.FileHelpers&version=3.2.1

var FB_VERSION = "11.2.0";
var NUGET_VERSION = "11.2.0.1";
var FB_VERSION = "13.1.0";
var NUGET_VERSION = "13.1.0";

var BUILD_COMMIT = EnvironmentVariable("BUILD_COMMIT") ?? "DEV";
var BUILD_NUMBER = EnvironmentVariable("BUILD_NUMBER") ?? "DEBUG";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace HelloFacebookSample
// [ContentProvider (new [] { "com.facebook.app.FacebookContentProvider355198514515820" },
// Name="com.facebook.FacebookContentProvider",
// Exported=true)]
[BroadcastReceiverAttribute]
[BroadcastReceiver(Exported = true)]
[IntentFilterAttribute (new [] { "com.facebook.platform.AppCallResultBroadcast" })]
public class HelloFacebookBroadcastReceiver : FacebookBroadcastReceiver
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -15,7 +15,7 @@
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidApplication>True</AndroidApplication>
<AssemblyName>HelloFacebookSample</AssemblyName>
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v12.0</TargetFrameworkVersion>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<AndroidSupportedAbis>armeabi-v7a;x86;arm64-v8a;x86_64</AndroidSupportedAbis>
</PropertyGroup>
Expand Down Expand Up @@ -67,7 +67,6 @@
<AndroidResource Include="Resources\drawable-xhdpi\icon.png" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\layout\" />
<Folder Include="Resources\drawable-xxhdpi\" />
<Folder Include="Resources\drawable-xxxhdpi\" />
</ItemGroup>
Expand Down Expand Up @@ -105,10 +104,8 @@
<Name>facebook-share</Name>
</ProjectReference>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.1.0.1" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.1.0.1" />
</ItemGroup>

<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public class HelloFacebookSampleActivity : FragmentActivity
Latitude = (47.6097),
Longitude = (-122.3331)
};


private Login l = new Xamarin.Facebook.Login.Login();
const String PENDING_ACTION_BUNDLE_KEY = "com.facebook.samples.hellofacebook:PendingAction";
Button postStatusUpdateButton;
Button postPhotoButton;
Expand All @@ -74,7 +75,7 @@ protected override void OnCreate (Bundle savedInstanceState)
base.OnCreate (savedInstanceState);

FacebookSdk.SdkInitialize (this.ApplicationContext);

callbackManager = CallbackManagerFactory.Create ();

var loginCallback = new FacebookCallback<LoginResult> {
Expand Down Expand Up @@ -182,7 +183,7 @@ protected override void OnResume ()
{
base.OnResume ();

AppEventsLogger.ActivateApp (this);
AppEventsLogger.ActivateApp(this.Application);

UpdateUI ();
}
Expand All @@ -205,7 +206,7 @@ protected override void OnPause ()
{
base.OnPause ();

AppEventsLogger.DeactivateApp (this);
// AppEventsLogger.DeactivateApp (this.Application);
}

protected override void OnDestroy ()
Expand Down Expand Up @@ -253,21 +254,21 @@ private void HandlePendingAction ()

void PostStatusUpdate ()
{
var profile = Profile.CurrentProfile;

var linkContent = new ShareLinkContent.Builder ()
.SetContentTitle ("Hello Facebook")
.SetContentDescription ("The 'Hello Facebook' sample showcases simple Facebook integration")
.SetContentUrl (Android.Net.Uri.Parse ("http://developer.facebook.com/docs/android"))
.JavaCast<ShareLinkContent.Builder> ()
.Build ();

if (canPresentShareDialog)
shareDialog.Show (linkContent);
else if (profile != null && HasPublishPermission ())
ShareApi.Share (linkContent, shareCallback);
else
pendingAction = PendingAction.POST_STATUS_UPDATE;
//var profile = Profile.CurrentProfile;

//var linkContent = new ShareLinkContent.Builder ()
// .SetContentTitle ("Hello Facebook")
// .SetContentDescription ("The 'Hello Facebook' sample showcases simple Facebook integration")
// .SetContentUrl (Android.Net.Uri.Parse ("http://developer.facebook.com/docs/android"))
// .JavaCast<ShareLinkContent.Builder> ()
// .Build ();

//if (canPresentShareDialog)
// shareDialog.Show (linkContent);
//else if (profile != null && HasPublishPermission ())
// ShareApi.Share (linkContent, shareCallback);
//else
// pendingAction = PendingAction.POST_STATUS_UPDATE;

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.facebook.samples.hellofacebook" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="29" />
<application android:label="@string/app_name" android:icon="@drawable/icon" android:theme="@android:style/Theme.NoTitleBar">
</application>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.facebook.samples.hellofacebook" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="31" />
<application android:label="@string/app_name" android:icon="@drawable/icon" android:theme="@android:style/Theme.NoTitleBar"></application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -16,7 +16,7 @@
<AndroidApplication>True</AndroidApplication>
<AssemblyName>MessengerSendSample</AssemblyName>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v12.0</TargetFrameworkVersion>
<AndroidSupportedAbis>armeabi-v7a;x86;arm64-v8a;x86_64</AndroidSupportedAbis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down Expand Up @@ -105,4 +105,4 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>
</Project>
2 changes: 1 addition & 1 deletion Facebook.Android/source/GenParamNames/GenParamNames.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
15 changes: 13 additions & 2 deletions Facebook.Android/source/GenParamNames/MethodArgument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@
class MethodArgument
{
public string Type { get; set; }
public string Name { get; set; }

public string TypeOriginal { get; set; }
public string Name { get; set; }

public string Url { get; set; }

public bool IsGenericArgument { get; set; } = false;

public string ToString()
{
return Name+ "("+Type + ")";
}
}


}
Loading