capture image doesnt display in imageview - android

im doing a simple android camera application that capture one picture then display it. the capturing part is working however i cant display it on the imageview.there wasnt any error but in one of the logcat stated this
Bitmap too large to be uploaded into a texture (3120x4208, max=4096x4096)
MainActivity.java
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import java.io.File;
public class MainActivity extends Activity {
Button button;
ImageView imageView;
static final int CAM_REQUEST = 1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button) findViewById(R.id.button);
imageView = (ImageView) findViewById(R.id.image_view);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent camera_intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = getfile();
camera_intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(camera_intent,CAM_REQUEST);
}
});
}
private File getfile(){
File folder = new File("sdcard/camera_app");
if(!folder.exists()){
folder.mkdir();
}
File image_file = new File (folder, "cam_image.jpg");
return image_file;
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String path = "sdcard/camera_app/cam_image.jpg";
imageView.setImageDrawable(Drawable.createFromPath(path));
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.lala.camera.MainActivity"
android:orientation="vertical">
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="Capture Image"
android:id="#+id/button"
android:layout_gravity="center_horizontal"
/>
<ImageView
android:layout_width="350dp"
android:layout_height="300dp"
android:id="#+id/image_view"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
/>
</LinearLayout>
AndroidManifest.xml
<
?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.amirul.camera">
<uses-feature android:name="android.hardware.camera2"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Your image is too large you have to resize it.
Try this:
imageView.setImageDrawable(resize(Drawable.createFromPath(path)));
private Drawable resize(Drawable image) {
Bitmap bitmap = ((BitmapDrawable)image).getBitmap();
Bitmap bitmapResized = Bitmap.createScaledBitmap(bitmap , WIDTH, HEIGHT, false);
return new BitmapDrawable(getResources(), bitmapResized);
}

Related

ImageView is not showing image in Xiomi Smartphone

I have written a program to browse image gallery and show the selected image in the ImageView using AndroidStudio. I have got a sample code from Select Image From Gallery And Display It On ImageView, Issue On Nexus 5
It is working well in stock android running Smartphone like LG L70 set. But no image is visible on the imageview for Xiomi 4A.
For experimentation, I have written the same code in Eclipse editor. The code developed by Eclipse running well both LG L70 and Xiomi 4A.
Hence, it is clear that code is not problem. The problem must be from IDE. Could you please help me to solve this problem. Where should I modify the code, so that it will run on Xiomi developed by AndroidStudio.
Codes in gdrive.
Code
package com.example.nasif.xiomi_imageview2;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import static android.widget.Toast.LENGTH_LONG;
public class MainActivity extends AppCompatActivity
{
private ImageView imgProfile;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imgProfile = (ImageView)findViewById(R.id.imgProfileIV);
final Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
// Perform action on click
//new MyAsyncTask(this).execute("ppppp");
Log.d("MyTag", "1");
ImageProfile();
}
});
}
public void ImageProfile()
{
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 100);
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent)
{
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
switch(requestCode)
{
case 100:
if(resultCode == RESULT_OK)
{
Uri selectedImage = imageReturnedIntent.getData();
imgProfile.setImageURI(selectedImage);
Log.d("MyTag", "#: " + selectedImage);
Toast.makeText(MainActivity.this, "#: " + selectedImage, LENGTH_LONG).show();
}
}
}
}
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.nasif.xiomi_imageview2">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.nasif.xiomi_imageview2.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
<ImageView
android:id="#+id/imgProfileIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/a"
android:onClick="ImageProfile" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/imgProfileIV"
android:text="Button" />
</RelativeLayout>

pdf reader from assets folder

I want to create a pdf reader with android studio. I added a pdf file to assets folder. I used seekbar. But code doesn't show anything. What's wrong?
I share all prog
Mainactivity.java
package enespolat.polat.com.kuranahmethusrev;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.pdf.PdfRenderer;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import java.io.File;
import uk.co.senab.photoview.PhotoViewAttacher;
public class MainActivity extends AppCompatActivity {
LinearLayout pagerSection;
SeekBar pageSeekbar;
ImageView pageView;
TextView tvCounter;
PdfRenderer.Page sayfa;
PhotoViewAttacher pva;
int pageCount=0;
int currPage=0;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pageSeekbar=(SeekBar)findViewById(R.id.sbPager);
pagerSection=(LinearLayout)findViewById(R.id.llPageCounter);
pageView=(ImageView)findViewById(R.id.iv);
tvCounter=(TextView)findViewById(R.id.tvCounter);
render();
pva = new PhotoViewAttacher(pageView);
pva.setMaximumScale(10.0f);
pageSeekbar.setMax(605);
pageSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
#Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b)
{
currPage=i;
showCurrentPageIndicator();
}
#Override
public void onStartTrackingTouch(SeekBar seekBar)
{
}
#Override
public void onStopTrackingTouch(SeekBar seekBar)
{
currPage=seekBar.getProgress();
render();
}
});
}
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (pageView != null)
pageView.invalidate();
}
void showCurrentPageIndicator()
{
tvCounter.setText(""+(currPage+1));
pagerSection.setVisibility(View.VISIBLE);
pagerSection.postDelayed(new Runnable() {
#Override
public void run() {
pagerSection.setVisibility(View.GONE);
}
},700);
}
private void render()
{
try {
File dlFolder = new File(Environment.getExternalStorageDirectory(), "Download");
File pdfFile = new File(dlFolder, "kuran.pdf");
PdfRenderer renderer = new PdfRenderer(ParcelFileDescriptor.open(pdfFile,ParcelFileDescriptor.MODE_READ_ONLY));
sayfa = renderer.openPage(currPage);
Bitmap bitmap=Bitmap.createBitmap(sayfa.getWidth(),sayfa.getHeight(), Bitmap.Config.ARGB_8888);
Matrix m=pageView.getImageMatrix();
m.setScale(1.0f, 1.0f);
Rect rect=new Rect(0,0,sayfa.getWidth(),sayfa.getHeight());
sayfa.render(bitmap,rect,m,PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);
//img.setImageMatrix(m);
pageView.setImageBitmap(bitmap);
pageView.invalidate();
/**/
sayfa.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
layout folder
<?xml version="1.0" encoding="utf-8" ?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="#+id/activity_main" android:layout_width="match_parent" android:background="#FFFFFF" android:layout_height="match_parent">
<ImageView android:id="#+id/iv" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="#+id/ly" />
- <LinearLayout android:background="#88333333" android:layout_width="match_parent" android:paddingRight="5dp" android:paddingLeft="5dp" android:id="#+id/ly" android:paddingBottom="12dp" android:paddingTop="12dp" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true">
<SeekBar android:id="#+id/sbPager" android:layout_width="match_parent" android:layout_height="wrap_content" />
</LinearLayout>
- <LinearLayout android:visibility="gone" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="40dp" android:background="#88333333" android:id="#+id/llPageCounter" android:layout_centerVertical="true" android:layout_centerHorizontal="true">
<TextView android:layout_width="match_parent" android:layout_height="match_parent" android:textColor="#FFFFFF" android:textStyle="bold" android:id="#+id/tvCounter" android:text="355" android:textSize="40sp" android:gravity="center" />
</LinearLayout>
</RelativeLayout>
manifest
<?xml version="1.0" encoding="utf-8" ?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="enespolat.polat.com.kuranahmethusrev">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
- <application android:allowBackup="true" android:icon="#mipmap/ic_launcher" android:label="#string/app_name" android:supportsRtl="true" android:theme="#style/AppTheme">
- <activity android:name=".MainActivity">
- <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

android studio.. there are no error in code but there are exeption

I am writing code in Android studio its no error in the code but when I make run it did not work and show me "FATAL EXCEPTION" error when I make Run.
here my code:
In MainActivity.java
package com.example.hayfa.sharingwithmultimedia;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import java.io.File;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
Uri uri;
ImageView mImageView = (ImageView) findViewById(R.id.imageView);
static final int REQUEST_IMAGE_CAPTURE = 1;
public void dispatchTakePictureIntent(View view){
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if(takePictureIntent.resolveActivity(getPackageManager())!=null){
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
mImageView.setImageBitmap(imageBitmap);
}
File image=new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "picture.jpg");
uri= Uri.fromFile(image);
data.putExtra(MediaStore.EXTRA_OUTPUT, uri);
}
public void sendImage(View view){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM, "This is my text to send");
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "From my app");
intent.setType("image/jpeg");
startActivity(Intent.createChooser(intent,"Share image to "));
}
}
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hayfa.sharingwithmultimedia">
<uses-feature android:name="android.hardware.camera"
android:required="true"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
contentmain.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.example.hayfa.sharingwithmultimedia.MainActivity"
tools:showIn="#layout/activity_main">
<ImageView
android:layout_width="300dip"
android:layout_height="300dip"
android:id="#+id/imageView"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" TAKE PICTURE"
android:onClick="dispatchTakePictureIntent"
android:id="#+id/button"
android:layout_below="#+id/imageView"
android:layout_centerHorizontal="true"
android:layout_marginTop="41dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SHARE PICTURE"
android:onClick="sendImage"
android:id="#+id/button2"
android:layout_below="#+id/button"
android:layout_alignLeft="#+id/button"
android:layout_alignStart="#+id/button" />
</RelativeLayout>
You cannot use findViewById until after you call setContentView(...) in onCreate().
First only declare your ImageView
private ImageView mImageView;
and then assign it in onCreate()
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mImageView = (ImageView) findViewById(R.id.imageView);
}

Select Image from Gallery Not Posting to App in Android Studio?

I am really new and been looking through a few tutorials on Android Studio to get some help to make a simple imageview that just picks an image from gallery and displays it on the page. I can get it click and pull up gallery but it wont display after choosing the image from gallery. I looked over a few tutorials and I dont see anything I am missing? Any help?
android manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="adamnate.ddproject" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission a
ndroid:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
MainActivity.xml
package adamnate.ddproject;
import android.content.Intent;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
private static final int RESULT_LOAD_IMAGE = 1;
ImageView imageToUpload;
Button bUploadImage;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageToUpload = (ImageView) findViewById(R.id.imageToUpload);
bUploadImage = (Button) findViewById(R.id.bUploadImage);
imageToUpload.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), 1);
}
});
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
if (requestCode ==11)
imageToUpload.setImageURI(data.getData());
}
}
}
activity_main
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:padding="10dp"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:id="#+id/imageToUpload"
android:layout_gravity="center_horizontal" />
<Button
android:id="#+id/bUploadImage"
android:text="Upload Image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</ScrollView>
Use this
requestCode == 1
and not
requestCode == 11
because you put 1 on the requestCode param when you call startActivityForResult()

Why placing a call programatically gives error message "Internet Calling not Supported"?

This is my code:
public String a_number;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_make_the_call);
//
callButton = (ImageButton)findViewById(R.id.call_button);
aCall = (TextView)findViewById(R.id.number_a);
a_number = aCall.getText().toString();
}
public void makeCallFunction(View view) {
String temp = "";
temp = "tel:"+a_number;
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse(temp));
startActivity(callIntent);
}
My XML file contains:
<ImageButton
android:id="#+id/call_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:src="#drawable/dial"
android:onClick="makeCallFunction"/>
I have added the following in my manifest file:
<uses-permission android:name="android.permission.CALL_PHONE"/>
I searched my best for answers but found nothing helpful..
EDIT:
When I give a value directly, the call gets placed now.
Eg:
callIntent.setData(Uri.parse("tel:9876543210"));
But the problem remains when I read the number from my text view and try to place call with that number.
Can someone help me out?
Thanks in advance
If there's some alternate way to implement call, that'd help too.
Disable SIP Internet Calling and VoIP on your emulator or debugging device. This is the steps for Samsung Galaxy S4 :
go to settings > call > disable internet calling(in bottom)
I don't know what you are doing wrong, but see for yourself a working example :
MakeTheCallActivity.java
package com.example.makethecall;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MakeTheCallActivity extends ActionBarActivity {
private EditText mEditText;
private Button mButton;
private final String TAG = "MakeTheCallActivity";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_make_the_call);
mButton = (Button)findViewById(R.id.call_button);
mButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mEditText = (EditText)findViewById(R.id.phone_number);
String phoneNumber = mEditText.getText().toString();
Log.d(TAG, phoneNumber);
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber));
startActivity(intent);
}
});
}
}
activity_make_the_call.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".MakeTheCallActivity"
android:orientation="vertical">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/phone_number" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="call"
android:id="#+id/call_button" />
</LinearLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sauravsamamt.makethecall" >
<uses-permission android:name="android.permission.CALL_PHONE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MakeTheCallActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
You can see I'm not using a hardcoded number. Make sure you enter a valid number. That's it.

Categories

Resources