I can't find my mistakes......
while studying social login(google, facebook), almost don't know what to do...
I tried my best, but couldn't find errors.
When I connect my android devices and run on them, my devices get jammed.
So I should force terminate my app.
here is my code
androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.acepeter.smartcalendar">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"
tools:replace="android:supportsRtl">
<activity android:name=".SignupActivity"/>
<activity android:name=".MainActivity"/>
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".BaseActivity" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id"
tools:replace="android:value" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<activity android:name=".LoginActivity"
android:windowSoftInputMode="stateHidden|adjustResize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
</application>
</manifest>
splashactivity.java
public class SplashActivity extends AppCompatActivity {
/*
앱이 맨처음 실행하면 띄어지는 로딩 화면
앱에서 필요한 네트워크 연결, 데이터베이스 연결
설정 값 적용 등의 앱에서 처음에 해야할 기능을 수행하기 위한 화면
앱 또는 서버 점검 알림창을 띄우는 화면
Remote Config(원격 구성)
서버에서 앱의 대한 설정을 해줄 수 있습니다.
설정 : 사용자가 사용하는 설정이 아닌 앱 관리자가 모든 앱의 설정을
관리하기 위한 기능
*/
FirebaseRemoteConfig remoteConfig;
LinearLayout container;
// #Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_logo);
// startLoading();
// mAuth = FirebaseAuth.getInstance();
// }
// private void startLoading() {
// Handler handler = new Handler();
// handler.postDelayed(new Runnable() {
// #Override
// public void run() {
// finish();
// }
// }, 2000);
//}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_logo);
container = findViewById(R.id.splash_layout_container);
// 전체 화면
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
startLoading();
remoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
.setMinimumFetchIntervalInSeconds(100)
.build();
remoteConfig.setConfigSettingsAsync(configSettings);
remoteConfig.setDefaultsAsync(R.xml.remote_config_defaults);
remoteConfig.fetchAndActivate()
.addOnCompleteListener(new OnCompleteListener<Boolean>() {
#Override
public void onComplete(#NonNull Task<Boolean> task) {
if (task.isSuccessful()) {
Log.i("RemoteConfig", "Remote Success");
} else {
Log.i("RemoteConfig", "Remote Failed");
}
displayMessage();
}
});
}
private void displayMessage() {
// 서버에 저장된 설정 값을 가져오도록 함.
String background = remoteConfig.getString(getString(R.string.theme_color));
boolean caps = remoteConfig.getBoolean("splash_message_caps");
String message = remoteConfig.getString("splash_message");
container.setBackgroundColor(Color.parseColor(background));
if(caps) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(message)
.setPositiveButton("확인", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
builder.create().show();
}else {
// 다음 화면으로 넘어감
Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
startActivity(intent);
finish();
}
}
private void startLoading() {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
#Override
public void run() {
finish();
}
}, 2000);
}
}
How do I change the phone call user interface? Like I have my own dialer layout and contacts layout but how do I change the calling UI. So, when the call is going on, can I remove the speaker button for example?
Here is my dialer scene that I have created: Dialer Picture
But I don't know how to edit this screen: Calling Picture
EDIT: I have already built the UI, I just can not get it to show during call!
Here is the code for as a simpler version:
public class MainActivity extends Activity {
private Button callBtn;
private Button dialBtn;
private EditText number;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
number = (EditText) findViewById(R.id.phoneNumber);
callBtn = (Button) findViewById(R.id.call);
dialBtn = (Button) findViewById(R.id.dial);
// add PhoneStateListener for monitoring
MyPhoneListener phoneListener = new MyPhoneListener();
TelephonyManager telephonyManager =
(TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
// receive notifications of telephony state changes
telephonyManager.listen(phoneListener,PhoneStateListener.LISTEN_CALL_STATE);
callBtn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
try {
// set the data
String uri = "tel:"+number.getText().toString();
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(uri));
startActivity(callIntent);
}catch(Exception e) {
Toast.makeText(getApplicationContext(),"Your call has failed...",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
});
dialBtn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
try {
String uri = "tel:"+number.getText().toString();
Intent dialIntent = new Intent(Intent.ACTION_DIAL, Uri.parse(uri));
startActivity(dialIntent);
}catch(Exception e) {
Toast.makeText(getApplicationContext(),"Your call has failed...",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
});
}
private class MyPhoneListener extends PhoneStateListener {
private boolean onCall = false;
#Override
public void onCallStateChanged(int state, String incomingNumber) {
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
// phone ringing...
Toast.makeText(MainActivity.this, incomingNumber + " calls you",
Toast.LENGTH_LONG).show();
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
// one call exists that is dialing, active, or on hold
Toast.makeText(MainActivity.this, "on call...",
Toast.LENGTH_LONG).show();
//because user answers the incoming call
onCall = true;
break;
case TelephonyManager.CALL_STATE_IDLE:
// in initialization of the class and at the end of phone call
// detect flag from CALL_STATE_OFFHOOK
if (onCall == true) {
Toast.makeText(MainActivity.this, "restart app after call",
Toast.LENGTH_LONG).show();
// restart our application
Intent restart = getBaseContext().getPackageManager().
getLaunchIntentForPackage(getBaseContext().getPackageName());
restart.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(restart);
onCall = false;
}
break;
default:
break;
}
}
}
}
Thanks!
Add calling permission in manifest
<uses-permission android:name="android.permission.CALL_PHONE" />
Then need to check if call button pressed. for that use below intent filter
<intent-filter>
<action android:name="android.intent.action.CALL_BUTTON" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
and when firing the UI
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.DIAL" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tel" />
</intent-filter>
that means your calling activity in manifest will be something like this
<activity
android:name="com.example.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- open activity when establishing a call -->
<intent-filter>
<action android:name="android.intent.action.CALL_PRIVILEGED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel" />
</intent-filter>
</activity>
since API 23 it is possible, see Replacing default Phone app on Android 6 and 7 with InCallService arekolek.
Kotlin version: Simple Phone
Java version: Simple Phone Dialer
EDIT
As recommended, Below is the simplest java version.
Below is shown the Manifest with the intent-filter needed.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.aliton.customphonecall">
<uses-permission android:name="android.permission.CALL_PHONE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
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>
<activity
android:name=".DialerActivity" >
<intent-filter>
<!-- Handle links from other applications -->
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.DIAL" />
<!-- Populate the system chooser -->
<category android:name="android.intent.category.DEFAULT" />
<!-- Handle links in browsers -->
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tel" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.DIAL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<service
android:name=".CallService"
android:permission="android.permission.BIND_INCALL_SERVICE">
<meta-data
android:name="android.telecom.IN_CALL_SERVICE_UI"
android:value="true" />
<intent-filter>
<action android:name="android.telecom.InCallService" />
</intent-filter>
</service>
<activity android:name=".CallActivity"></activity>
</application>
</manifest>
The MainActivity just have a Button with an Intent redirecting to the DialerActivity.
Below is the DialerActivity. In this Activity, you will set your app as default in order to make call with your UI.
public class DialerActivity extends AppCompatActivity {
private static final int REQUEST_CALL_PHONE = 10;
EditText phoneNumber;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dialer);
phoneNumber = (EditText) findViewById(R.id.etNumber);
Button bCall = (Button) findViewById(R.id.btnCall);
offerReplacingDefaultDialer();
bCall.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
makeCall();
}
});
}
private void makeCall() {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_GRANTED) {
Uri uri = Uri.parse("tel:"+phoneNumber.getText().toString().trim());
Intent Call = new Intent(Intent.ACTION_CALL, uri);
//Toast.makeText(this, "Entered makeCall()", Toast.LENGTH_SHORT).show();
Log.i("debinf Dialer", "Entered makeCall()");
startActivity(Call);
} else {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CALL_PHONE}, REQUEST_CALL_PHONE);
}
}
private void offerReplacingDefaultDialer() {
if (getSystemService(TelecomManager.class).getDefaultDialerPackage() != getPackageName()) {
Intent ChangeDialer = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER);
ChangeDialer.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, getPackageName());
startActivity(ChangeDialer);
}
}
#Override
public void onRequestPermissionsResult(int requestCode, #NonNull String[] permissions, #NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_CALL_PHONE) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
makeCall();
} else {
Toast.makeText(this, "calling permission denied", Toast.LENGTH_LONG).show();
}
//return;
}
}
}
Here is how InCallService is implemented to manage the calls.
public class CallService extends InCallService {
OngoingCallObject ongoingCallObject;
#Override
public void onCallAdded(Call call) {
super.onCallAdded(call);
new OngoingCallObject().setCall(call);
//Intent CallAct = new Intent(this, CallActivity.class);
//startActivity(CallAct);
CallActivity.start(this, call);
}
#Override
public void onCallRemoved(Call call) {
super.onCallRemoved(call);
new OngoingCallObject().setCall(null);
}
}
Here is how the Object is implemented.
public class OngoingCallObject {
private static Call call;
private Object callback = new Callback() {
#Override
public void onStateChanged(Call call, int state) {
super.onStateChanged(call, state);
Log.i("debinf OngoingObj", "state is "+state);
}
};
public void setCall(Call call) {
if (this.call != null) {
this.call.unregisterCallback((Call.Callback)callback);
}
if (call != null) {
call.registerCallback((Call.Callback)callback);
Log.i("debinf OngoingObj", "call.getState() is "+call.getState());
}
this.call = call;
}
public void answer() {
//assert this.call != null;
if (this.call != null) {
this.call.answer(VideoProfile.STATE_AUDIO_ONLY);
}
}
public void hangup() {
//assert this.call != null;
if (this.call != null) {
this.call.disconnect();
}
}
}
And finally, the CallActivity where you launch your UI.
public class CallActivity extends AppCompatActivity {
TextView callInfo;
Button answer, hangup;
private String number;
private OngoingCallObject ongoingCall;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_call);
ongoingCall = new OngoingCallObject();
answer = (Button) findViewById(R.id.answer);
hangup = (Button) findViewById(R.id.hangup);
callInfo = (TextView) findViewById(R.id.callInfo);
number = Objects.requireNonNull(getIntent().getData().getSchemeSpecificPart());
callInfo.setText("Calling number : "+number);
answer.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//Toast.makeText(CallActivity.this, "Answer button", Toast.LENGTH_SHORT).show();
ongoingCall.answer();
}
});
hangup.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
ongoingCall.hangup();
}
});
}
public static void start(Context context, Call call) {
Intent intent = new Intent(context, CallActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(call.getDetails().getHandle());
context.startActivity(intent);
}
}
Here is the xml for DialerActivity: activity_dialer.xml
<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"
tools:context=".DialerActivity">
<EditText
android:id="#+id/etNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Tel number"/>
<Button
android:id="#+id/btnCall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="CallActivity"
android:layout_below="#+id/etNumber" />
</RelativeLayout>
Here is the xml for CallActivity: activity_call.xml
<android.support.constraint.ConstraintLayout 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"
tools:context=".CallActivity">
<TextView
android:id="#+id/callInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.3"
tools:text="Hello World!" />
<Button
android:id="#+id/answer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Answer"
app:layout_constraintBaseline_toBaselineOf="#+id/hangup"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/hangup" />
<Button
android:id="#+id/hangup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hang up"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/answer"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/callInfo" />
</android.support.constraint.ConstraintLayout>
I hope it helps!
EDIT:
Actually the api 23 was release, check this answer. Keep in mind that some devices may not support this functionality.
PREVIEW:
The actual calling view (what you see during calls) CAN`T be changed.
To be more specific, some parts of android CAN NOT be overridden,
android has his core and as developers we have limited access to this
core. In your case you can override dialer but you can`t
override actual phone call view.
You can't do anything about this, until android team decided to share
this core feature with us (developers).
Build your own Dialer UI. Check this out.
You will need an Activity to handle the intent and then displaying a custom UI is your business.
my program is not working ,
i have some kind of a problem with the surfaceviewexample class.
Unable to start activity java.lang.NullPointerException.
i am trying to push on the tut5 button which i made to start my surfaceview.
what is the reason for it ?
what am i doing wrong ?
SurfaceViewExample.java
public class SurfaceViewExample extends Activity implements View.OnTouchListener{
OurView v;
Bitmap ball;
float x,y;
#Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
v=new OurView(this);
v=setOnTouchListener(this);
ball= BitmapFactory.decodeResource(getResources(),R.drawable.ball);
x=y=0;
setContentView(v);
}
private OurView setOnTouchListener(SurfaceViewExample surfaceViewExample) {
return null;
}
#Override
protected void onPause(){
super.onPause();
v.pause();
}
#Override
protected void onResume(){
super.onResume();
v.resume();
}
#Override
public boolean onTouch(View v , MotionEvent me) {
return false;
}
public class OurView extends SurfaceView implements Runnable {
Thread t=null;
SurfaceHolder holder;
boolean isItOK=false;
public OurView(Context context){
super(context);
holder=getHolder();
}
#Override
public void run()
{
while (isItOK==true)
{
if(!holder.getSurface().isValid()){
continue;
}
Canvas c=holder.lockCanvas();
c.drawARGB(255,150,150,10);
c.drawBitmap(ball,x,y,null);
holder.unlockCanvasAndPost(c);
}
}
public void pause(){
isItOK=false;
while(true){
try{
t.join();
}catch (InterruptedException e){
e.printStackTrace();
}
break;
}
t=null;
}
public void resume(){
isItOK=true;
t=new Thread(this);
t.start();
}
}
}
menu.java
public class menu extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView (com.example.youtubeproject.R.layout.activity_main);
final MediaPlayer buttonSound = MediaPlayer.create(menu.this,
com.example.youtubeproject.R.raw.button_click);
Button tut1= (Button)findViewById(com.example.youtubeproject.R.id.tutorial1);
Button tut2= (Button)findViewById(com.example.youtubeproject.R.id.tutorial2);
Button tut3= (Button)findViewById(com.example.youtubeproject.R.id.tutorial3);
Button tut4=(Button)findViewById(com.example.youtubeproject.R.id.tutorial4);
Button tut5=(Button)findViewById(com.example.youtubeproject.R.id.tutorial5);
tut1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
buttonSound.start();
setContentView (com.example.youtubeproject.R.layout.tutorial1);
Intent TutorialIntent=new Intent("com.example.youtubeproject.TUTORIAL1");
startActivity(TutorialIntent);
//startActivity(new Intent("com.example.youtubeproject.TUTORIAL1"));
}
});
tut2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
buttonSound.start();
startActivity(new Intent("com.example.youtubeproject.TUTORIALTWO"));
}
});
tut3.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
buttonSound.start();
setContentView (com.example.youtubeproject.R.layout.wallpapaer);
Intent TutorialIntent=new
Intent("com.example.youtubeproject.TUTORIALTHREE");
startActivity(TutorialIntent);
}
});
tut4.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
buttonSound.start();
Intent TutorialIntent=new
Intent("com.example.youtubeproject.TUTORIALFOUR");
startActivity(TutorialIntent);
//setContentView (com.example.youtubeproject.R.layout.wallpapaer);
//Intent TutorialIntent=new
Intent("com.example.youtubeproject.TUTORIALTHREE");
//startActivity(TutorialIntent);
}
});
tut5.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
buttonSound.start();
//startActivity(new Intent("com.example.youtubeproject.TUTORIALFIVE"));
Intent TutorialIntent=new
Intent("com.example.youtubeproject.TUTORIALFIVE");
startActivity(TutorialIntent);
//setContentView (com.example.youtubeproject.R.layout.wallpapaer);
//Intent TutorialIntent=new
Intent("com.example.youtubeproject.TUTORIALTHREE");
//startActivity(TutorialIntent);
}
});
}
public boolean onCreateOptionsMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
MenuInflater awesome=getMenuInflater();
awesome.inflate(com.example.youtubeproject.R.menu.main_menu,menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item){
switch(item .getItemId()){
case com.example.youtubeproject.R.id.menuSweet:
startActivity(new Intent("com.example.youtubeproject.SWEET"));
return true;
case com.example.youtubeproject.R.id.menuToast:
Toast andEggs=Toast.makeText(menu.this,"this is a toast
",Toast.LENGTH_LONG);
andEggs.show();
return true;
}
return false;
}
}
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.youtubeproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.SET_WALLPAPER"></uses-permission>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".menu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.youtubeproject.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Tutorial1"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.youtubeproject.TUTORIAL1" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".TutoralTwo"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.youtubeproject.TUTORIALTWO" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".TutorialThree"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.youtubeproject.TUTORIALTHREE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".SurfaceViewExample"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.youtubeproject.TUTORIALFIVE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".TutorialFour"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.youtubeproject.TUTORIALFOUR" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Sweet"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog" >
<intent-filter>
<action android:name="com.example.youtubeproject.SWEET" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Declare you SurfaceViewExample activity into Menifest like that;
<activity
android:name="com.example.youtubeproject.SurfaceViewExample" >
</activity>
Manifest.xml
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
>
<activity
android:name="com.teamandy.MainActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:theme="#*android:style/Theme.Black.NoTitleBar" android:name="com.teamandy.Choosetype" android:screenOrientation="portrait" />
<activity android:theme="#*android:style/Theme.Black.NoTitleBar" android:name="com.teamandy.frames1" android:screenOrientation="portrait" />
</application>
Main Activity:
this.startb=(Button)findViewById(R.id.btn_start);
this.startb.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent strtint=new Intent(MainActivity.this, Choosetype.class);
//strtint.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
strtint.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
strtint.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
strtint.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(strtint);
finish();
}
});
Choosetype Activity:
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.choosefrm);
}
public void f1(View v ){
Choosetype.number=1;
this.mcontexts=this;
startActivity();
}
public void f2(View v){
Choosetype.number=2;
this.mcontexts=this;
startActivity();
.........................unti f20 etc. used
i have problem with sending Broadcast receive from one activity to other ..its not working my code is below..pls refer to it ..
sending class is:
public class SendBroadcast extends Activity {
public static String BROADCAST_ACTION = "com.unitedcoders.android.broadcasttest.SHOWTOAST";
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
sendBroadcast();
}
});
}
public void sendBroadcast(){
Intent broadcast = new Intent();
broadcast.setAction("com.unitedcoders.android.broadcasttest.SHOWTOAST");
sendBroadcast(broadcast);
}
}
and reciving class is :
public class ToastDisplay extends Activity {
private BroadcastReceiver receiver = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
Log.i("asdasd","sdasdasd");
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "%%%%%%%%%%%%received", Toast.LENGTH_SHORT).show();
}
};
#Override
protected void onResume() {
IntentFilter filter = new IntentFilter();
filter.addAction(SendBroadcast.BROADCAST_ACTION);
registerReceiver(receiver, filter);
super.onResume();
}
#Override
protected void onPause() {
unregisterReceiver(receiver);
super.onPause();
}
}
Manifest file is ::::
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.unitedcoders.android.broadcasttest"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="4" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".SendBroadcast"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ToastDisplay">
<intent-filter>
<action android:name="com.unitedcoders.android.broadcasttest.SHOWTOAST"> </action>
</intent-filter>
</activity>
</application>
</manifest>
you have not registered your Receiver in Manifest :registered as
<receiver android:name="receiver">
<intent-filter>
<action
android:name="com.unitedcoders.android.broadcasttest.SHOWTOAST"/>
</intent-filter>
</receiver>