Tuesday, June 30, 2015

How to call built-in applications using intents in Android

Developing android apps specially the games required opengl for providing better graphics. We have seen how to get started with opengl es for android, and will continue the opengl tutorial  for android programming. Today's we are going to learn an important concept in this android development tutorial, how to call built-in applications using intents in Android. This give advantage to developer taking in-build apps and throw user to them if required. Calling built in applications using intents in Android is important as it give user more choices. For example in an app you want user make a call or open a document (pdf) let you use the in-build apps, take off the burden in developing those apps. You might have seen in previous Whatsapp, which let user call from within the app (now they have their own voip).

Android intent example

Lets get started with how to use intent in android. The following Try It Out demonstrates how to call some of the built-in applications commonly found on an Android device. 

Prerequisite

In this android intent example you need the Android Studio or Eclipse with ADT plugin and Android SDK tool. It is also necessary that you must know about some fundamentals of Java and XML as well as about the Android device. We also assume here that you know hello world program for developing android apps. This is a simple beginners tutorial, which hardly take you half an hour to understand, and doing yourself. I am doing this in Android Studio but you may choose Eclipse (remember google officially going to end support for ADT at the end of 2015).

Creating New Project

1. First step : Open Android Studio and Create a new project by selecting 'Start a new Android Studio Project'. Give it a name MyIntent and a package name in.ruks. You can have your own application package names. Click next, choose minimum SDK, in ours case it is API 14 : Android 4.0 (IceCreamSandwich), which accounts for close to 90% of activated android devices. Again click next, select the Blank Activity, Click next. Android will ask to name the activity, keep the default names, click on finish. Android Studio will create the the new Android Project with all the necessary files.

how to create new project in android studio for developing android apps

Set up Project Layout

We are going to use 6 built-in application in this android development tutorial. They are -
  1. Gallery
  2. Call Log
  3. Contact
  4. Dailler
  5. Browser
  6. Map
2. Second step : Now the time to set up the layout of our project. We are going to call 6 built-in applications using intents, hence we will place a button for each in activity_main.xml. You can drag and drop 6 button on the layout or simply create by coding the activity_main.xml file. Check out the code below and add it to activity_main.xml


    


3. Third step :  It's bad idea to have the hard coded string in the project. So in this android intent example code, we are given name to each of the button within the strings.xml, which is under the values folder in Android Studio. Add the code below in it -

    MyIntent
    Hello world!
    Settings
    Contacts
    Gallery
    Call a number
    Open Call Logs
    Open Browser
    Open Map
    Exit


Now we have our layout design for this android intent example, we are going to code the java file to call built-in applications using intents.

Creating  event handler

4. Fourth step : In our MainActivity.java file, we are going to declare the button for each of the Button we have created in our layout file.

Button Gallery = (Button) findViewById(R.id.button_gallery);
Button CallLog = (Button) findViewById(R.id.button_calllog);
Button Contacts = (Button) findViewById(R.id.button_contacts);
Button Map = (Button) findViewById(R.id.button_map);
Button Dail = (Button) findViewById(R.id.button_Dail);
Button Broswer = (Button) findViewById(R.id.button_browser);
5. Fifth step : Our Buttons are ready to have some action, now its time to attach the event handler to them. One by one we are going to call setOnClickListener method on each of our Button and call built-in applications. Just place the following code in MainActivity.java
package in.ruks.myintent;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button Gallery = (Button) findViewById(R.id.button_gallery);
        Button CallLog = (Button) findViewById(R.id.button_calllog);
        Button Contacts = (Button) findViewById(R.id.button_contacts);
        Button Map = (Button) findViewById(R.id.button_map);
        Button Dail = (Button) findViewById(R.id.button_Dail);
        Button Broswer = (Button) findViewById(R.id.button_browser);

        Contacts.setOnClickListener(new Button.OnClickListener(){

            @SuppressWarnings("deprecation")
            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub

                Intent myIntent = new Intent();

                myIntent.setAction(Intent.ACTION_VIEW);
                myIntent.setData(android.provider.Contacts.People.CONTENT_URI);
                startActivity(myIntent);

            }
        });

        Gallery.setOnClickListener(new Button.OnClickListener(){

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub

                Intent myIntent = new Intent();

                myIntent.setAction(Intent.ACTION_VIEW);
                myIntent.setData(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
                startActivity(myIntent);

            }
        });
        Dail.setOnClickListener(new Button.OnClickListener(){

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub

    /*Intent myIntent = new Intent();

    myIntent.setAction(Intent.ACTION_VIEW);
    myIntent.setData(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
    startActivity(myIntent);*/

                Intent i = new Intent(android.content.Intent.ACTION_DIAL,
                        Uri.parse("tel:+918147656011"));
                startActivity(i);
            }
        });
        CallLog.setOnClickListener(new Button.OnClickListener(){

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub

                Intent myIntent = new Intent();

                myIntent.setAction(Intent.ACTION_CALL_BUTTON);
                startActivity(myIntent);
            }
        });

        Broswer.setOnClickListener(new Button.OnClickListener(){

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub

                Intent i = new Intent(android.content.Intent.ACTION_VIEW,
                        Uri.parse("http://www.openglprojects.in"));
                startActivity(i);
            }
        });

        Map.setOnClickListener(new Button.OnClickListener(){

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub

                Intent myIntent = new Intent();

                myIntent.setAction(Intent.ACTION_VIEW);
                myIntent.setData(Uri.parse("geo:37.827500,-122.481670"));
                startActivity(myIntent);

            }
        });



    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);

        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // TODO Auto-generated method stub
        //return super.onOptionsItemSelected(item);
        if(item.getItemId()==R.id.action_exit){
            this.finish();
            return true;
        }
        return false;
    }


}

Declare Activity in  AndroidManifest

6. Final step : If you have basic knowledge of developing android apps then you must know that, every activity you have in your application must be declared in your AndroidManifest.xml file. So Know place the following code in AndroidManifest.xml file.



    
        
            
                

                
            
        
    



We finished with out coding session, time to see our work in action. Go to Run menu(alt+u) click Run App or directly run the  program with shift +F10.

Final Thoughts

In this how to call built-in applications using intents tutorial, we have call only 6 in build apps, while you can call others as well. You can replace the mobile number with our own in android intent example activity replacing the tel:+918147656011. Same can be done with website url and map Lat Long values by replacing http://www.openglprojects.in and geo:37.827500,-122.481670 respectively in MainActivity.java file. 

Hope you liked this android development tutorial, feel free to ask anything via comments. We assume that this small step will help you in developing android apps.
Read more...

Friday, June 19, 2015

OpenGL Projects Android App available on Google Play Store


Hello fellow reader of OpenGL Projects blog, we have just launched our own Android App.

Now the OpenGL Projects Android App available on Google Play Store for your Android smartphones and tablets.This is the first version of our app on Google Play Store.This app let you have all the feature of OpenGL projects in your pocket. You don't have to on browsing any web browser rather can easily view all the articles on our Android App. Let take the advantage of this app.

Download OpenGL Projects Android App available on Google Play Store

The OpenGL projects Android app is compatible with almost all the Android Devices including the Old Android OS 2.2 and new updated Android 5.1. We hope you will download the app and take the full advantage with you.

Please not forget to rate our App and give us feedback to make it better.



Read more...

Tuesday, May 19, 2015

3D Solar System OpenGL graphics program


We have seen many good programs on Solar System in OpenGL. Today we are going to present you a mode 3D modeled version of solar system graphics program. You might encountered the previous very simple solar system opengl program which remain at the top seen post on this blog. But this program is very much different as it includes many of the other space objects like stars and comets, also it has orbit and axis for each planet, which can be controlled by user. Also we can control the stars as well with keyboard.

Features of 3D OpenGL graphics program

This 3D graphics program is a very good project that can both be use for submitting at college's mini project or even in course for learning graphics. Unlike the previous solar system graphic project this program has many features.

Updating this post...........

For Code and Demo Contact at 8147656011 or whatsapp at 7022162923
Read more...

Friday, May 15, 2015

Buy Project Report for any OpenGL Projects Mentioned

Hello  Fellow Readers!

We at OpenGL Projects works out to give you free source code for any of Computer graphics projects. We try hard to reach each of you via various platform including social media - Facebook, Google Plus etc, Comments, emails and whatsapp but due to time constraint and other works we are not able to reach you at the time. We ask for apology for not answering each of you. But you need to Understand our problem and hope you will.

We try hard to put source code easily downloadable but if you face problem we are sorry for it. Also we need feedback from you guys, which you all not providing to us. Try submit altered project so we can help other students as well in future. 

Now the main purpose of this post. Since we are busy in working we are not able to focus more on this blog. Most of you ask for source code, which we think is ok, but for report we hope that you are able to download a sample and do it your self. Our thought has gone wrong. So we decided to give services to those students who can't do it themselves. Also we don't have project report for all the projects. Since we need to devotee our precious time so we put a minimal fee for it. So now, you can Buy Project Report for any OpenGL Projects Mentioned in this blog.

Our new services includes -

  • Full Project Report on the OpenGL Projects (any) at Rs 500.
  • PPT creation for the Project (any) at Rs 200.
  • Video demo that helps line by line understanding of project at Rs 5000.
  • New Project(not on blog) with code and documentations (including videos) at Rs 10000.
  • Specific High Profile Project with code and documentations (including videos) starting at Rs 15000.
If you interested call 8147656011 or Whatsapp at 7022162923. Don't waste time on Fake calling and negotiations. 


Read more...

Friday, May 8, 2015

OpenGL Tutorial in C/C++ For Doubly Linked List

There are many way by which you can learn OpenGL. Try Book from Edward Angle. You can also get many simple OpenGL tutorials in this blog as well.

Linked list is tough concept in C/C++. Today we are going to talk about it. There are mainly two kind of linked list - 
  1. Singly Linked list - The linked list that only one link node.
  2. Doubly Linked list - The linked list with two link node.
In the previous post we had already talk about the Singly Linked List, in this OpenGL Tutorial post we are going to learn about C/C++ For Doubly Linked List.

 Operation on Doubly Linked List

Like Singly Linked List many operations can be done on doubly linked list at both end of the node(both link). These are few doubly linked list operation which is given below –
  1. Creation
  2. Insert at Starting
  3. Insert at left
  4. Insert at Right
  5. Insert Front
  6. Insert Rear
  7. Delete at Left
  8. Delete at Right
  9. Delete Front
  10. Delete Rear
  11. Display
Before Going to the graphical OpenGL program for the Doubly Linked List, kindly refer to C program for Doubly Linked it first. If you understand it, then only go for opengl program.

Similar to the C++ Program, the Graphics program for Doubly Linked list also declare struct for three nodes – info, rlink, llink. Similar to Singly Linked List this program also takes input in different window while display in different window.


To display the node three simple rectangle has being drawn. These are linked with the line to other elements in the list. Drawing this in OpenGL is quite easy but need to understand the concept of C, so before going to this OpenGL tutorial program better read C program first.

Different menu has is given to user to choose the operation on the doubly linked list. Just need to right click and choose the Option. While Doing this kindly do slowly and do not do rubbish work else it might not work for you. This is not that effective graphics program but we can make it one window workable program as future enhancement.

Download Source code for Doubly Linked List OpenGL Tutorial Program


Read more...