I'm following single activity approach. I have navigation toolbar, whenever i go to other screens (fragments) instead of hamburger icon i will have back arrow.
What i want to achieve is, pop my current fragment using action on pressing toolbar back arrow.
I've tried
requireActivity().getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
NavHostFragment.findNavController(EventDetailsFragment.this)
.navigate(R.id.action_nav_event_details_to_nav_home);
}
});
Run Code Online (Sandbox Code Playgroud)
But not getting the call over there, i checked by running app in debug mode.
android android-toolbar android-mvvm android-navigation-graph
下面是我正在使用的代码
通知服务类
private void showCallNotification(Map<String, String> dataMap) {
notificationId = (int) (System.currentTimeMillis() % 10000);
Intent intent = new Intent(getApplicationContext(), ReceiveCallActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.setAction(Intent.ACTION_ANSWER)
.putExtra(AppConstants.CALL_STATUS, AppConstants.CALL_ACCEPTED)
.putExtra("title", dataMap.get("title"))
.putExtra("action", dataMap.get("action"));
Intent cancelIntent = new Intent(getApplicationContext(), VideoCallReceiver.class)
.setAction(AppConstants.INCOMING_CALL_BROADCAST_ACTION)
.putExtra(AppConstants.CALL_STATUS, AppConstants.CALL_DECLINED)
.putExtra("notificationId", notificationId);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent cancelPendingIntent = PendingIntent.getBroadcast(this, 0, cancelIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action declineAction = new NotificationCompat.Action(android.R.drawable.ic_menu_call, getString(R.string.decline_call), cancelPendingIntent);
NotificationCompat.Action acceptAction = new NotificationCompat.Action(android.R.drawable.ic_menu_call, getString(R.string.accept_call), pendingIntent);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, AppConstants.CALL_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(dataMap.get("sender"))
.setContentText(getString(R.string.incoming_call))
.setColor(getResources().getColor(R.color.notification_color))
.setAutoCancel(true) …Run Code Online (Sandbox Code Playgroud) 这个错误突然开始出现。
Node : v10.16.3
React native : 0.60.5
react-native-cli: 2.0.1
Run Code Online (Sandbox Code Playgroud)
捆绑失败:错误:无法
stream从/Users/username/React Native/SampleApp/node_modules/browser-stdout/index.js以下位置解析模块:模块stream在 Haste 模块映射中不存在
它给出了这一行的错误:
var WritableStream = require('stream').Writable
Run Code Online (Sandbox Code Playgroud)
我尝试通过 npm 安装“流”
npm install stream
Run Code Online (Sandbox Code Playgroud)
然后其他类似的错误开始出现。
我在实时应用程序上遇到 UnsupportedOperationException 崩溃。所有崩溃都与 Moto Android 11 设备有关。可以看出它与 onKeyUp 有某种关系。但仍然不知道如何重现或解决这个问题。任何帮助,将不胜感激。
Fatal Exception: java.lang.UnsupportedOperationException: Tried to obtain display from a Context not associated with one. Only visual Contexts (such as Activity or one created with Context#createWindowContext) or ones created with Context#createDisplayContext are associated with displays. Other types of Contexts are typically related to background entities and may return an arbitrary display.
at android.app.ContextImpl.getDisplay(ContextImpl.java:2580)
at android.content.ContextWrapper.getDisplay(ContextWrapper.java:1030)
at android.content.ContextWrapper.getDisplay(ContextWrapper.java:1030)
at android.app.Activity.onKeyUp(Activity.java:3859)
at android.view.KeyEvent.dispatch(KeyEvent.java:2866)
at android.app.Activity.dispatchKeyEvent(Activity.java:4176)
at androidx.core.app.ComponentActivity.superDispatchKeyEvent(ComponentActivity.java:122)
at androidx.core.view.KeyEventDispatcher.dispatchKeyEvent(KeyEventDispatcher.java:84)
at androidx.core.app.ComponentActivity.dispatchKeyEvent(ComponentActivity.java:140)
at androidx.appcompat.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:558)
at …Run Code Online (Sandbox Code Playgroud) 我尝试通过导航抽屉活动创建一个新项目。使用视图模型自动生成片段。单击导航菜单时,它不会导航到相应的片段。
构建.gradle
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.0.0'
implementation 'androidx.navigation:navigation-ui:2.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
Run Code Online (Sandbox Code Playgroud)
主Activity.class
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
DrawerLayout drawer = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);
// Passing each menu …Run Code Online (Sandbox Code Playgroud) android navigation-drawer android-navigationview android-navigation-graph