Search This Blog

Saturday, 16 August 2014

How to use Google AdMob in Windows Phone app

Step 1. Firstly download Google Admob SDK for Windows Phone from the link below
Step 2. Go to your AdMob account and create an ad unit for your app
Fill in the details to create an AdUnit as follows
  • Fill in your app name and select platform
  • Select the type of AdUnit and fill in the name for the AdUnit. You can customize the look of the ad whenever you want
  • Click on save and an AdUnit id would be generated.All done you are ready setting thing up for AdMob.
Step 3. Unzip the SDK files and you will find a GoogleAds.dll file in it. Create a new project and add a reference to this dll file in your project.















Note: If the GoogleAds.dll is showing as incompatible then follow these steps
  • In the file explorer, navigate to the Google Ads.dll
  • Right click the dll file and click ‘Properties’
  • In the ‘General’ tab, at the bottom, there will be an ‘unblock’ button
  • Unblock the dll file and add it again in your project
You will need to add the following capabilities in your app for ads to appear!
  • ID_CAP_NETWORKING: Access to network services is required when requesting ads.
  • ID_CAP_WEBBROWSERCOMPONENT: Required since the AdView is a web browser.
  • ID_CAP_MEDIALIB_PLAYBACK: Provides access for currently playing media items.
  • ID_CAP_MEDIALIB_AUDIO: Provides read access to audio items in media library.
That's it... :)
now run the emulator...and wait for a while..adds will appear...!!!

Create an add unit with Google AdMob

Create an ad unit

Complete the following steps to create an ad unit for an existing app.
  1. Sign in to your AdMob account at https://apps.admob.com.
  2. Click the Monetize tab.
  3. Select your application from the All apps list on the left-hand side.
  4. Click + New ad unit.
  5. Click Banner or Interstitial.
  6. Provide the following details for the ad unit:
For Banner:
  1. Ad type: Choose the ad type(s) allowed for this ad unit. You can choose any combination of text and image by checking the boxes. Checking both boxes is recommended since unchecking either of the boxes might limit the revenue generated by the ad unit. Unchecking all of the boxes will result in an error. You must choose at least one ad type for each ad unit.
  2. Automatic refresh Determine how often a new ad impression is generated. You can choose not to refresh or to refresh ads every 30 to 120 seconds. We recommend setting a refresh rate between 45 and 60 seconds.
  3. Text ad style: Select a text ad style that complements your app. You can use the standard style or customize your own style.
  4. Ad unit name: Enter a unique name and description that will help you find this ad unit later (e.g., Top Banner on Home).
For Interstitial:
  1. Ad type: Choose the ad type(s) allowed for this ad unit. You can choose any combination of text, image, and video by checking the boxes. Checking all three boxes is recommended since unchecking some of the boxes might limit the revenue generated by the ad unit. Unchecking all of the boxes will result in an error. You must choose at least one ad type for each ad unit.
  2. Interstitial timeout: Determine how long the app should attempt to receive an ad. You can select from 3 to 10 seconds and it must be a whole number.
  3. Ad unit name: Enter a unique name and description that will help you find this ad unit later (e.g., Interstitial on level complete).
7.  Click Save. You'll see the ad unit ID for this ad unit on the top.
8.  Click Done to return to the Monetize tab or click Send an email with these instructions to have instructions sent to you via email.



Monday, 2 September 2013

Windows Phone Emulator- Shortcut Keys


Keyboard shortcuts are very useful while developing your Windows Phone applications, that basically allows to reduce the development and testing time. The following keyboard shortcuts substitute the physical buttons on a Windows Phone Emulator.


  •  F1 = Back arrow button. Escape key can also be used.
  •  F2 = Windows Start button
  •  F3 = Search button
  •  F6 = Camera button that is pressed halfway
  •  F7 = Camera button that is fully pressed
  •  F9 = Volume up
  •  F10 = Volume down
  •  F12 = Lock device/Power button. Press it twice to see the lock screen.
  •  PAGE DOWN = When text box is highlight, moves visual keyboard down, and you can use your physical keyboard for input
  •  PAGE UP = When text box is highlight, moves visual keyboard up.
  •  PAUSE/BREAK = Toggle keyboard
 ******   HAPPY CODING   ******

Thursday, 22 August 2013

Playing media content on Windows Phone 7 with MediaElement

You can play Mp3 sounds by using Media Element. but VS does not support more then 10 MediaElemnets.
as in my case, i made a Funny Ringtones App, in which i uploaded 30 Ringtones.I just use only one media element.
here is the code: which will surely help you...!!!

Xaml Code:

 <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Margin="0,0,0,-68" Background="#FFF7C4EC">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel Background="#FFAAC57B"  x:Name="TitlePanel" Grid.Row="0" Margin="-19,17,0,28"/>

 <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <MediaElement   x:Name="m1" AutoPlay="True" Margin="0,105,10,-36"/>
            <ListBox Height="auto" Width="auto" Margin="0,110,0,0"  >
             
                <!--1-->
                <Grid  Tap="Grid_Tap_1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="11*"/>
                        <ColumnDefinition Width="3*"/>
                    </Grid.ColumnDefinitions>

                <!--2-->
                    <Button  BorderBrush="LightGray"  Content="" BorderThickness="0" Click="Button_Click_1"  HorizontalAlignment="Left" VerticalAlignment="Top" Width="114" Margin="-20,-24,0,-20" Height="124">
                        <Button.Background>
                        <ImageBrush Stretch="Fill" ImageSource="/images/a.png"/>
                        </Button.Background>
                    </Button>
                    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Answer_The_Phone" VerticalAlignment="Bottom" Margin="94,0,0,4" RenderTransformOrigin="2.13,1.496" Height="43" Width="270" Foreground="#FF0F0F0F" FontSize="30" FontFamily="Segoe WP Semibold" Grid.ColumnSpan="2"/>
 </Grid>

                <!--2-->
                <Grid Tap="Grid_Tap_2">
                    <Button  BorderBrush="LightGray"  BorderThickness="0" Content="" Click="Button_Click_2"  HorizontalAlignment="Left" VerticalAlignment="Top" Width="114" Margin="-20,-24,0,-20" Height="124">
                        <Button.Background>
                        <ImageBrush Stretch="Fill" ImageSource="/images/b.png"/>
                        </Button.Background>
                    </Button>
                    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Baby_bayi_nangis" VerticalAlignment="Bottom" Margin="94,0,0,4" RenderTransformOrigin="2.13,1.496" Height="43" Width="270" Foreground="#FF0F0F0F" FontSize="30" FontFamily="Segoe WP Semibold"/>
</Grid>

                <!--3-->
                <Grid Tap="Grid_Tap_3">
                    <Button  BorderBrush="LightGray"  BorderThickness="0" Content="" Click="Button_Click_3"  HorizontalAlignment="Left" VerticalAlignment="Top" Width="114" Margin="-20,-24,0,-18" Height="122">
                        <Button.Background>
                         <ImageBrush Stretch="Fill" ImageSource="/images/c.png"/>
                        </Button.Background>
                    </Button>
                    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Baby_Gangster" VerticalAlignment="Bottom" Margin="94,0,0,4" RenderTransformOrigin="2.13,1.496" Height="43" Width="270" Foreground="#FF0F0F0F" FontSize="30" FontFamily="Segoe WP Semibold"/>
</Grid>

                <!--4-->
                <Grid Tap="Grid_Tap_4">
                    <Button  BorderBrush="LightGray"  BorderThickness="0" Content="" Click="Button_Click_4"  HorizontalAlignment="Left" VerticalAlignment="Top" Width="114" Margin="-20,-24,0,-18" Height="122">
                        <Button.Background>
                        <ImageBrush Stretch="Fill" ImageSource="/images/e.png"/>
                        </Button.Background>
                    </Button>
                    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Boss_Sms_Tone" VerticalAlignment="Bottom" Margin="94,0,0,4" RenderTransformOrigin="2.13,1.496" Height="43" Width="270" Foreground="#FF0F0F0F" FontSize="30" FontFamily="Segoe WP Semibold"/>
 </Grid>

                <!--5-->
                <Grid Tap="Grid_Tap_5">
                    <Button  BorderBrush="LightGray"  BorderThickness="0" Content="" Click="Button_Click_5" HorizontalAlignment="Left" VerticalAlignment="Top" Width="114" Margin="-20,-24,0,-18" Height="122">
                        <Button.Background>
                        <ImageBrush Stretch="Fill" ImageSource="/images/d.png"/>
                        </Button.Background>
                    </Button>
                    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Cartoon_Laugh" VerticalAlignment="Bottom" Margin="94,0,0,4" RenderTransformOrigin="2.13,1.496" Height="43" Width="270" Foreground="#FF0F0F0F" FontSize="30" FontFamily="Segoe WP Semibold"/>
                </Grid>

                <!--6-->
                <Grid Tap="Grid_Tap_6">
                    <Button  BorderBrush="LightGray"  BorderThickness="0"  Content=""  Click="Button_Click_6" HorizontalAlignment="Left" VerticalAlignment="Top" Width="114" Margin="-20,-24,0,-18" Height="122">
                        <Button.Background>
                        <ImageBrush Stretch="Fill" ImageSource="/images/h.png"/>
                        </Button.Background>
                    </Button>
                    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Cute_kid_sms" VerticalAlignment="Bottom" Margin="94,0,0,4" RenderTransformOrigin="2.13,1.496" Height="43" Width="270" Foreground="#FF0F0F0F" FontSize="30" FontFamily="Segoe WP Semibold"/>
                   </Grid>

                <!--7-->
                <Grid Tap="Grid_Tap_7">
                    <Button BorderBrush="LightGray"  BorderThickness="0" Content="" Click="Button_Click_7"  HorizontalAlignment="Left" VerticalAlignment="Top" Width="114" Margin="-20,-24,0,-18" Height="122">
                        <Button.Background>
                       <ImageBrush Stretch="Fill" ImageSource="/images/j.png"/>
                        </Button.Background>
                    </Button>
                    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Dad_is_calling" VerticalAlignment="Bottom" Margin="94,0,0,4" RenderTransformOrigin="2.13,1.496" Height="43" Width="270" Foreground="#FF0F0F0F" FontSize="30" FontFamily="Segoe WP Semibold"/>
                    <Button BorderBrush="LightGray" BorderThickness="0" Content="" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,-99,0" Width="100" Height="80">
                         </Grid>

                <!--8-->
                <Grid Tap="Grid_Tap_8">
                    <Button BorderBrush="LightGray"  BorderThickness="0" Content="" Click="Button_Click_8"  HorizontalAlignment="Left" VerticalAlignment="Top" Width="114" Margin="-20,-24,0,-18" Height="122">
                        <Button.Background>
                        <ImageBrush Stretch="Fill" ImageSource="/images/k.png"/>
                        </Button.Background>
                    </Button>
                    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Funny_funny_funny" VerticalAlignment="Bottom" Margin="94,0,0,4" RenderTransformOrigin="2.13,1.496" Height="43" Width="270" Foreground="#FF0F0F0F" FontSize="30" FontFamily="Segoe WP Semibold"/>
                   </Grid>

                <!--9-->
                <Grid Tap="Grid_Tap_9">
                    <Button  BorderBrush="LightGray"  BorderThickness="0"   Content="" Click="Button_Click_9"  HorizontalAlignment="Left" VerticalAlignment="Top" Width="114" Margin="-20,-24,0,-18" Height="122">
                        <Button.Background>
                        <ImageBrush Stretch="Fill" ImageSource="/images/l.png"/>
                        </Button.Background>
                    </Button>
                    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Funny_laugh" VerticalAlignment="Bottom" Margin="94,0,0,4" RenderTransformOrigin="2.13,1.496" Height="43" Width="270" Foreground="#FF0F0F0F" FontSize="30" FontFamily="Segoe WP Semibold"/>
                    </Grid>

                <!--10-->
                <Grid Tap="Grid_Tap_10">
                    <Button BorderBrush="LightGray"  BorderThickness="0" Content="" Click="Button_Click_10"  HorizontalAlignment="Left" VerticalAlignment="Top" Width="114" Margin="-20,-24,0,-18" Height="122">
                        <Button.Background>
                       <ImageBrush Stretch="Fill" ImageSource="/images/n.png"/>
                        </Button.Background>
                    </Button>
                    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Funny_msg_tone" VerticalAlignment="Bottom" Margin="94,0,0,4" RenderTransformOrigin="2.13,1.496" Height="43" Width="270" Foreground="#FF0F0F0F" FontSize="30" FontFamily="Segoe WP Semibold"/>
</Grid>

                <!--11-->
                <Grid Tap="Grid_Tap_11">
                    <Button BorderBrush="LightGray"  BorderThickness="0"  Content="" Click="Button_Click_11"  HorizontalAlignment="Left" VerticalAlignment="Top" Width="114" Margin="-20,-24,0,-18" Height="122">
                        <Button.Background>
                        <ImageBrush Stretch="Fill" ImageSource="/images/o.png"/>
                        </Button.Background>
                    </Button>
                    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Funny_sms" VerticalAlignment="Bottom" Margin="94,0,0,4" RenderTransformOrigin="2.13,1.496" Height="43" Width="270" Foreground="#FF0F0F0F" FontSize="30" FontFamily="Segoe WP Semibold"/>
                    </Grid>


 </Grid>

Cs File code:

  public MainPage()
        {
            InitializeComponent();
        }
 private void Grid_Tap_1(object sender, System.Windows.Input.GestureEventArgs e)
        {
            m1.Source = new Uri("/Answer_the_Phone.mp3", UriKind.Relative);
            m1.Play();
        }

        private void Grid_Tap_2(object sender, System.Windows.Input.GestureEventArgs e)
        {
            m1.Source = new Uri("/baby_bayi_nangis.mp3", UriKind.Relative);
            m1.Play();
        }

        private void Grid_Tap_3(object sender, System.Windows.Input.GestureEventArgs e)
        {
            m1.Source = new Uri("/Baby_Gangster.mp3", UriKind.Relative);
            m1.Play();
        }

        private void Grid_Tap_4(object sender, System.Windows.Input.GestureEventArgs e)
        {
            m1.Source = new Uri("/Boss_Sms_Tone.mp3", UriKind.Relative);
            m1.Play();

        }

        private void Grid_Tap_5(object sender, System.Windows.Input.GestureEventArgs e)
        {
            m1.Source = new Uri("/Cartoon_Laugh.mp3", UriKind.Relative);
            m1.Play();
        }

        private void Grid_Tap_6(object sender, System.Windows.Input.GestureEventArgs e)
        {
            m1.Source = new Uri("/Cute_Kid_Sms.mp3", UriKind.Relative);
            m1.Play();
        }

        private void Grid_Tap_7(object sender, System.Windows.Input.GestureEventArgs e)
        {
            m1.Source = new Uri("/Dad_Is_Calling.mp3", UriKind.Relative);
            m1.Play();
        }

        private void Grid_Tap_8(object sender, System.Windows.Input.GestureEventArgs e)
        {
            m1.Source = new Uri("/Funny_Funny_Funny_09.mp3", UriKind.Relative);
            m1.Play();
        }

        private void Grid_Tap_9(object sender, System.Windows.Input.GestureEventArgs e)
        {
            m1.Source = new Uri("/Funny_Laugh.mp3", UriKind.Relative);
            m1.Play();
        }

        private void Grid_Tap_10(object sender, System.Windows.Input.GestureEventArgs e)
        {

            m1.Source = new Uri("/funny_msg_tone.mp3", UriKind.Relative);
            m1.Play();
        }

        private void Grid_Tap_11(object sender, System.Windows.Input.GestureEventArgs e)
        {
            m1.Source = new Uri("/Funny_Sms.mp3", UriKind.Relative);
            m1.Play();
        }

Hope this will help u.
Thnx....!!!


Monday, 12 August 2013

How to add colored finger painting in windows phone App

You can paint by dragging your fingers over the screen and you change color by “dipping your fingers in the paint buckets.
The app listens to the ‘MouseMove’-event and tracks you’re fingers position and add’s line-objects to a  canvas control. To make it possible to change color by ”dipping your fingers in the paint buckets” I’ve added a transparent ellipse control on top of every “paint bucket’, and connected up the ‘MouseLeftButtonDown’ event. Check out the source code below.


Xaml code:

<Grid x:Name="grid" Background="Transparent">
<Image x:Name="imgBackground" Source="bg.png" Height="800" Width="500" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0,0,0,0" />
<TextBlock x:Name="PageTitle" Foreground="#FF5B5B5B" Text="fingerpaint" Margin="21,10,0,28" Style="{StaticResource PhoneTextTitle1Style}" Grid.ColumnSpan="3" />
<Image x:Name="btnDelete" Source="delete.png" Opacity="0.75" Height="55" Width="55" VerticalAlignment="Top" HorizontalAlignment="Right" MouseLeftButtonDown="btnDelete_MouseLeftButtonDown" Grid.Column="1" Grid.ColumnSpan="2" />
<Canvas x:Name="paint" Background="Transparent" Width="500" Height="448" Margin="0,108,-20,244" Grid.ColumnSpan="3" />
<Ellipse x:Name="blue" Fill="#00F4F4F5" Height="86" Margin="114,0,115,38" Stroke="Transparent" VerticalAlignment="Bottom"/>
<Ellipse x:Name="yellow" Fill="#00F4F4F5" Height="44" Margin="176,0,100,137" Stroke="Transparent" VerticalAlignment="Bottom"/>
<Ellipse x:Name="black" Fill="#00F4F4F5" Height="45" Margin="0,0,78,151" Stroke="Transparent" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="94" Grid.ColumnSpan="2" />
<Ellipse x:Name="pink" Fill="#00F4F4F5" Height="73" Margin="0,0,57,66" Stroke="Transparent" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="130" Grid.ColumnSpan="2" />
</Grid>

 

C# code:



namespace fingerpaint
{
    public partial class MainPage : PhoneApplicationPage
    {
        private Point point;
        private Point old_point;
        private bool draw = false;
        private string colour = "white";
        public MainPage()
        {
            InitializeComponent();
            old_point = point;
            colour = "blue";
        }
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            blue.MouseLeftButtonDown += new MouseButtonEventHandler(selectColor);
            yellow.MouseLeftButtonDown += new MouseButtonEventHandler(selectColor);
            black.MouseLeftButtonDown += new MouseButtonEventHandler(selectColor);
            pink.MouseLeftButtonDown += new MouseButtonEventHandler(selectColor);
            paint.MouseMove += new MouseEventHandler(FingerMove);
            paint.MouseLeftButtonUp += new MouseButtonEventHandler(FingerUp);
            paint.MouseLeftButtonDown += new MouseButtonEventHandler(FingerDown);
        }
        void selectColor(object sender, MouseButtonEventArgs e)
        {
            Ellipse ellipse = sender as Ellipse;
            colour = ellipse.Name;
        }
        void FingerMove(object sender, MouseEventArgs e)
        {
            if (draw)
            {
                point = e.GetPosition(paint);
                Line line = new Line();
                if (colour == "blue")
                    line.Stroke = new SolidColorBrush(Color.FromArgb(255, 41, 159, 227));
                else if (colour == "yellow")
                    line.Stroke = new SolidColorBrush(Color.FromArgb(255, 226, 228, 43));
                else if (colour == "black")
                    line.Stroke = new SolidColorBrush(Color.FromArgb(255, 42, 42, 42));
                else if (colour == "pink")
                    line.Stroke = new SolidColorBrush(Color.FromArgb(255, 228, 29, 180));
                line.X1 = point.X;
                line.Y1 = point.Y;
                line.X2 = old_point.X;
                line.Y2 = old_point.Y;
                line.StrokeStartLineCap = PenLineCap.Round;
                line.StrokeEndLineCap = PenLineCap.Round;
                line.StrokeThickness = 15;
                line.Opacity = 0.5;
                paint.Children.Add(line);
                old_point = point;
            }
            old_point = point;
        }
        void FingerUp(object sender, MouseButtonEventArgs e)
        {
            draw = false;
        }
        void FingerDown(object sender, MouseButtonEventArgs e)
        {
            point = e.GetPosition(paint);
            old_point = point;
            draw = true;
        }
        private void btnDelete_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            paint.Children.Clear();
        }
    }
}