ICPMD
Integrated Cross-Platform Mobile Development
الثلاثاء، 3 مارس 2015
الخميس، 24 يوليو 2014
Built-in Camera Mobile Application (Android Target Project)
1. Manifest File:
AndroidManifest.xml
|
<?xml version="1.0" encoding="utf-8"?>
<!-- the package name and the version of the application extracted from the appinfo tag in the AM -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.icpmd.camera"
android:versionCode="1"
android:versionName="1.0.0.0">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<!-- the permissions list extracted from the permissions tag in the AM and the permissions database -->
<!-- the icon and label of the application extracted from the appinfo tag in the AM -->
<application android:icon="@drawable/applicationicon"
android:label="CameraApp" >
<!-- the default activity name is extracted from the appinfo tag in the AM -->
<activity android:name="edu.icpmd.camera.MainPage"
android:label="Camera" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
|
2. User Interface (UI) File:
Res/layout/mainpage.xml
|
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainPage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TableLayout
android:id="@+id/LayoutRoot"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:layout_width="match_parent" android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/TitlePanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="28dp"
android:paddingLeft="12dp"
android:paddingRight="0dp"
android:paddingTop="17dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MY APPLICATION" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="0dp"
android:paddingLeft="9dp"
android:paddingRight="0dp"
android:paddingTop="-7dp"
android:text="Camera App" />
</LinearLayout></TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="@+id/contentpanel"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:paddingBottom="0dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="0dp"
android:text="Camera App" >
<Button
android:id="@+id/capture" android:layout_height="wrap_content" android:layout_below="@+id/image1"
android:onClick="cameraCapture_Click"
android:paddingBottom="0dp"
android:paddingLeft="49dp"
android:paddingRight="0dp"
android:paddingTop="412dp"
android:layout_width="334dp"
android:layout_height="72dp"
android:text="Camera Capture" >
</Button>
<ImageView android:id="@+id/image1"
android:paddingBottom="0dp"
android:paddingLeft="25dp"
android:paddingRight="0dp"
android:paddingTop="19dp"
android:layout_width="406dp"
android:layout_height="269dp"
android:layout_below="@+id/button1"/>
</RelativeLayout>
</TableRow></TableLayout>
</LinearLayout>
|
3. Code File:
src/edu/icpmd/miniBrowser/MainPage.java
|
package edu.icpmd.camera;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
public class MainPage extends Activity {
ImageView image1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainpage);
image1 = (ImageView) findViewById(R.id.image1);
}
public void cameraCapture_Click(View arg0)
{
Intent cameraCaptureTask = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraCaptureTask,0)
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK)
{
Bitmap bmp = (Bitmap) data.getExtras().get("data");
image1.setImageBitmap(bmp);
}
}
}
|
Built-in Camera Mobile Application (Windows Phone 8 Source Project)
1. Manifest File:
Properties/WMAppManifest.xml
|
<?xml version="1.0" encoding="utf-8"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2012/deployment" AppPlatformVersion="8.0">
<DefaultLanguage xmlns="" code="en-US" />
<App xmlns="" ProductID="{86602b8c-3386-4d53-9061-4010038430fd}" Title="CameraApp" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="camera author" Description="Sample description" Publisher="camera" PublisherID="{52fa765c-ce63-4113-a70c-46ecadbcd9b2}">
<IconPath IsRelative="true" IsResource="false">Assets\ApplicationIcon.png</IconPath>
<Capabilities>
<Capability Name="ID_CAP_MEDIALIB_PLAYBACK" />
<Capability Name="ID_CAP_SENSORS" />
<Capability Name="ID_CAP_ISV_CAMERA" />
</Capabilities>
<Tasks>
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
</Tasks>
<Tokens>
<PrimaryToken TokenID="cameraToken" TaskName="_default">
<TemplateFlip>
<SmallImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileSmall.png</SmallImageURI>
<Count>0</Count>
<BackgroundImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileMedium.png</BackgroundImageURI>
<Title>camera</Title>
<BackContent>
</BackContent>
<BackBackgroundImageURI>
</BackBackgroundImageURI>
<BackTitle>
</BackTitle>
<DeviceLockImageURI>
</DeviceLockImageURI>
<HasLarge>
</HasLarge>
</TemplateFlip>
</PrimaryToken>
</Tokens>
<ScreenResolutions>
<ScreenResolution Name="ID_RESOLUTION_WVGA" />
<ScreenResolution Name="ID_RESOLUTION_WXGA" />
<ScreenResolution Name="ID_RESOLUTION_HD720P" />
</ScreenResolutions>
</App>
</Deployment>
|
2. User Interface (UI) file:
MainPage.xaml
|
<phone:PhoneApplicationPage
x:Class="camera.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="Camera App" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Content="Camera Capture" Height="72" HorizontalAlignment="Left" Margin="49,412,0,0" Name="capture" VerticalAlignment="Top" Width="334" Click="cameraCapture_Click" />
<Image Height="269" HorizontalAlignment="Left" Margin="25,19,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="406" />
</Grid>
</Grid>
</phone:PhoneApplicationPage>
|
3. Code file:
Source Code
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using camera.Resources;
using Microsoft.Phone.Tasks;
using System.Windows.Media.Imaging;
namespace camera
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{ InitializeComponent(); }
private void cameraCapture_Click(object sender, RoutedEventArgs e)
{
CameraCaptureTask cameraCaptureTask;
// initializes the task object, and identifies the method to run after the user completes the task.
cameraCaptureTask = new CameraCaptureTask();
cameraCaptureTask.Completed += new EventHandler<PhotoResult>(cameraCaptureTask_Completed);
cameraCaptureTask.Show();
}
void cameraCaptureTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
BitmapImage bmp = new BitmapImage(); bmp.SetSource(e.ChosenPhoto);
image1.Source = bmp;
}
}
}
}
|
الاشتراك في:
الرسائل (Atom)