Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8c4501a

Browse files
Hussein Al-RubayeHussein Al-Rubaye
Hussein Al-Rubaye
authored and
Hussein Al-Rubaye
committed
'servicebacground'
1 parent293f6a0 commit8c4501a

File tree

198 files changed

+3511
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+3511
-0
lines changed
50.5 KB
Binary file not shown.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion =14.0.24720.0
5+
MinimumVisualStudioVersion =10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") ="BroadcastAService","BroadcastAService\BroadcastAService.csproj","{5B7E6E7B-E4BD-42E5-9CF2-1C5DD6A22137}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) =preSolution
10+
Debug|Any CPU=Debug|Any CPU
11+
Release|Any CPU=Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) =postSolution
14+
{5B7E6E7B-E4BD-42E5-9CF2-1C5DD6A22137}.Debug|Any CPU.ActiveCfg=Debug|Any CPU
15+
{5B7E6E7B-E4BD-42E5-9CF2-1C5DD6A22137}.Debug|Any CPU.Build.0=Debug|Any CPU
16+
{5B7E6E7B-E4BD-42E5-9CF2-1C5DD6A22137}.Debug|Any CPU.Deploy.0=Debug|Any CPU
17+
{5B7E6E7B-E4BD-42E5-9CF2-1C5DD6A22137}.Release|Any CPU.ActiveCfg=Release|Any CPU
18+
{5B7E6E7B-E4BD-42E5-9CF2-1C5DD6A22137}.Release|Any CPU.Build.0=Release|Any CPU
19+
{5B7E6E7B-E4BD-42E5-9CF2-1C5DD6A22137}.Release|Any CPU.Deploy.0=Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) =preSolution
22+
HideSolutionNode =FALSE
23+
EndGlobalSection
24+
EndGlobal
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Any raw assets you want to be deployed with your application can be placed in
2+
this directory (and child directories) and given a Build Action of "AndroidAsset".
3+
4+
These files will be deployed with you package and will be accessible using Android's
5+
AssetManager, like this:
6+
7+
public class ReadAsset : Activity
8+
{
9+
protected override void OnCreate (Bundle bundle)
10+
{
11+
base.OnCreate (bundle);
12+
13+
InputStream input = Assets.Open ("my_asset.txt");
14+
}
15+
}
16+
17+
Additionally, some Android functions will automatically load asset files:
18+
19+
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ProjectToolsVersion="4.0"DefaultTargets="Build"xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<ConfigurationCondition=" '$(Configuration)' == ''">Debug</Configuration>
5+
<PlatformCondition=" '$(Platform)' == ''">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{5B7E6E7B-E4BD-42E5-9CF2-1C5DD6A22137}</ProjectGuid>
9+
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
10+
<OutputType>Library</OutputType>
11+
<AppDesignerFolder>Properties</AppDesignerFolder>
12+
<RootNamespace>BroadcastAService</RootNamespace>
13+
<AssemblyName>BroadcastAService</AssemblyName>
14+
<FileAlignment>512</FileAlignment>
15+
<AndroidApplication>true</AndroidApplication>
16+
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
17+
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
18+
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
19+
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
20+
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
21+
</PropertyGroup>
22+
<PropertyGroupCondition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
23+
<DebugSymbols>true</DebugSymbols>
24+
<DebugType>full</DebugType>
25+
<Optimize>false</Optimize>
26+
<OutputPath>bin\Debug\</OutputPath>
27+
<DefineConstants>DEBUG;TRACE</DefineConstants>
28+
<ErrorReport>prompt</ErrorReport>
29+
<WarningLevel>4</WarningLevel>
30+
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
31+
<AndroidLinkMode>None</AndroidLinkMode>
32+
</PropertyGroup>
33+
<PropertyGroupCondition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
34+
<DebugType>pdbonly</DebugType>
35+
<Optimize>true</Optimize>
36+
<OutputPath>bin\Release\</OutputPath>
37+
<DefineConstants>TRACE</DefineConstants>
38+
<ErrorReport>prompt</ErrorReport>
39+
<WarningLevel>4</WarningLevel>
40+
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
41+
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
42+
</PropertyGroup>
43+
<ItemGroup>
44+
<ReferenceInclude="AlertCenter.Android">
45+
<HintPath>..\Components\alert-center-1.0.6\lib\android\AlertCenter.Android.dll</HintPath>
46+
</Reference>
47+
<ReferenceInclude="Mono.Android" />
48+
<ReferenceInclude="mscorlib" />
49+
<ReferenceInclude="System" />
50+
<ReferenceInclude="System.Core" />
51+
<ReferenceInclude="System.Data" />
52+
<ReferenceInclude="System.EnterpriseServices" />
53+
<ReferenceInclude="System.Web.Services" />
54+
<ReferenceInclude="System.Xml.Linq" />
55+
<ReferenceInclude="System.Xml" />
56+
</ItemGroup>
57+
<ItemGroup>
58+
<CompileInclude="MainActivity.cs" />
59+
<CompileInclude="MyReciver.cs" />
60+
<CompileInclude="MyServices.cs" />
61+
<CompileInclude="Resources\Resource.Designer.cs" />
62+
<CompileInclude="Properties\AssemblyInfo.cs" />
63+
</ItemGroup>
64+
<ItemGroup>
65+
<NoneInclude="GettingStarted.Xamarin" />
66+
<NoneInclude="Resources\AboutResources.txt" />
67+
<NoneInclude="Assets\AboutAssets.txt" />
68+
</ItemGroup>
69+
<ItemGroup>
70+
<AndroidResourceInclude="Resources\layout\Main.axml" />
71+
</ItemGroup>
72+
<ItemGroup>
73+
<AndroidResourceInclude="Resources\values\Strings.xml" />
74+
</ItemGroup>
75+
<ItemGroup>
76+
<AndroidResourceInclude="Resources\drawable\Icon.png" />
77+
</ItemGroup>
78+
<ItemGroup>
79+
<NoneInclude="Properties\AndroidManifest.xml">
80+
<SubType>Designer</SubType>
81+
</None>
82+
</ItemGroup>
83+
<ItemGroup>
84+
<XamarinComponentReferenceInclude="alert-center">
85+
<Visible>False</Visible>
86+
<Version>1.0.6</Version>
87+
</XamarinComponentReference>
88+
</ItemGroup>
89+
<ItemGroup>
90+
<WebReferencesInclude="Web References\" />
91+
</ItemGroup>
92+
<ImportProject="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
93+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
94+
Other similar extension points exist, see Microsoft.Common.targets.
95+
<Target Name="BeforeBuild">
96+
</Target>
97+
<Target Name="AfterBuild">
98+
</Target>
99+
-->
100+
</Project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ProjectToolsVersion="14.0"xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<AndroidDesignerPreferredDevice>Nexus 4</AndroidDesignerPreferredDevice>
5+
<SelectedDevice>4" JellyBean %284.2%29 HDPI Phone</SelectedDevice>
6+
</PropertyGroup>
7+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<GettingStarted>
2+
<LocalContent>GS\Android\CS\AndroidApp\GettingStarted.html</LocalContent>
3+
<EmbeddedNavigation>false</EmbeddedNavigation>
4+
</GettingStarted>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
usingSystem;
2+
usingAndroid.App;
3+
usingAndroid.Content;
4+
usingAndroid.Runtime;
5+
usingAndroid.Views;
6+
usingAndroid.Widget;
7+
usingAndroid.OS;
8+
9+
namespaceBroadcastAService
10+
{
11+
[Activity(Label="BroadcastAService",MainLauncher=true,Icon="@drawable/icon")]
12+
publicclassMainActivity:Activity
13+
{
14+
intcount=1;
15+
16+
protectedoverridevoidOnCreate(Bundlebundle)
17+
{
18+
base.OnCreate(bundle);
19+
20+
// Set our view from the "main" layout resource
21+
SetContentView(Resource.Layout.Main);
22+
StartService(newIntent(this,typeof(MyServices)));
23+
// Get our button from the layout resource,
24+
// and attach an event to it
25+
Buttonbutton=FindViewById<Button>(Resource.Id.MyButton);
26+
27+
button.Click+=delegate{
28+
Intentintent=newIntent();
29+
intent.SetAction("com.alr.text");
30+
intent.PutExtra("MyData","Data from Activity1");
31+
SendBroadcast(intent);
32+
33+
};
34+
35+
}
36+
37+
38+
}
39+
}
40+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
usingSystem;
2+
usingSystem.Collections.Generic;
3+
usingSystem.Linq;
4+
usingSystem.Text;
5+
6+
usingAndroid.App;
7+
usingAndroid.Content;
8+
usingAndroid.OS;
9+
usingAndroid.Runtime;
10+
usingAndroid.Views;
11+
usingAndroid.Widget;
12+
usingAndroid.Telephony;
13+
usingAndroid.Provider;
14+
usingXamarin.Controls;
15+
16+
namespaceBroadcastAService
17+
{
18+
19+
[BroadcastReceiver(Exported=true,Label="SMS Receiver")]
20+
[IntentFilter(newstring[]{"android.provider.Telephony.SMS_RECEIVED","com.alr.text"})]
21+
publicclassMyReciver:Android.Content.BroadcastReceiver
22+
{
23+
privateconststringTag="SMSBroadcastReceiver";
24+
privateconststringIntentAction="android.provider.Telephony.SMS_RECEIVED";
25+
26+
publicoverridevoidOnReceive(Contextcontext,Intentintent)
27+
{
28+
// Log.Info(Tag, "Intent received: " + intent.Action);
29+
// read the SendBroadcast data
30+
if(intent.Action=="com.alr.text")
31+
{
32+
stringtext=intent.GetStringExtra("MyData")??"Data not available";
33+
Toast.MakeText(context,text,ToastLength.Short).Show();
34+
Intentintents=newIntent(context,typeof(MainActivity));
35+
intents.AddFlags(ActivityFlags.NewTask);
36+
context.StartActivity(intents);
37+
}
38+
//read incomming sms
39+
if(intent.Action==IntentAction)
40+
{
41+
42+
SmsMessage[]messages=Telephony.Sms.Intents.GetMessagesFromIntent(intent);
43+
44+
varsb=newStringBuilder();
45+
46+
for(vari=0;i<messages.Length;i++)
47+
{
48+
49+
sb.Append(string.Format("SMS From: {0}{1}Body: {2}{1}",messages[i].OriginatingAddress,
50+
System.Environment.NewLine,messages[i].MessageBody));
51+
}
52+
Toast.MakeText(context,sb.ToString(),ToastLength.Short).Show();
53+
}
54+
}
55+
}
56+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
usingSystem;
2+
usingSystem.Collections.Generic;
3+
usingSystem.Linq;
4+
usingSystem.Text;
5+
6+
usingAndroid.App;
7+
usingAndroid.Content;
8+
usingAndroid.OS;
9+
usingAndroid.Runtime;
10+
usingAndroid.Views;
11+
usingAndroid.Widget;
12+
usingSystem.Threading.Tasks;
13+
usingSystem.Threading;
14+
15+
namespaceBroadcastAService
16+
{
17+
[Service]
18+
classMyServices:IntentService
19+
{
20+
protectedoverridevoidOnHandleIntent(Intentintent)
21+
{
22+
23+
}
24+
publicoverrideStartCommandResultOnStartCommand(Intentintent,StartCommandFlagsflags,intstartId)
25+
{
26+
27+
// countine
28+
newTask(()=>
29+
{
30+
while(true)
31+
{
32+
Thread.Sleep(10000);
33+
Intentintents=newIntent();
34+
intents.SetAction("com.alr.text");
35+
intents.PutExtra("MyData","Data from service");
36+
SendBroadcast(intents);
37+
38+
39+
}
40+
41+
}).Start();
42+
43+
returnStartCommandResult.Sticky;
44+
}
45+
46+
47+
}
48+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifestxmlns:android="http://schemas.android.com/apk/res/android"package="BroadcastAService.BroadcastAService"android:versionCode="1"android:versionName="1.0"android:installLocation="auto">
3+
<uses-sdkandroid:minSdkVersion="16" />
4+
<applicationandroid:label="BroadcastAService"></application>
5+
<uses-permissionandroid:name="android.permission.BROADCAST_SMS" />
6+
<uses-permissionandroid:name="android.permission.READ_SMS" />
7+
<uses-permissionandroid:name="android.permission.RECEIVE_SMS" />
8+
<uses-permissionandroid:name="android.permission.INTERNET" />
9+
<receiverandroid:name=".MyReciver">
10+
<intent-filterandroid:priority="2147483647">
11+
<actionandroid:name="android.provider.Telephony.SMS_RECEIVED" />
12+
<actionandroid:name="com.alr.text" />
13+
<categoryandroid:name="android.intent.category.DEFAULT" />
14+
</intent-filter>
15+
</receiver>
16+
</manifest>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp