- Get link
- X
- Other Apps
Posts
Reading Writing json and Notification
- Get link
- X
- Other Apps
implementation ( "com.google.code.gson:gson:2.8.8" ) package com.example.jsonparsing import android.app.Notification import android.os.Bundle import android.provider.CalendarContract.Colors import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.annotation. RequiresApi import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime. Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview. Preview import com.example.jsonparsing.ui.them...
Moving to a new screen using different Activity
- Get link
- X
- Other Apps
package com.example.clicktonewactivity import android.content.Context import android.content.Intent import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview. Preview import com.example.clicktonewactivity.ui.theme.ClickToNewActivityTheme import androidx.compose.runtime.remember import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController import androidx.compose.foundation.layout.Column import androidx.compose.material3.Button import androidx.compose.runtime. Composable import androidx.comp...
Moving to a new screen within the same activity
- Get link
- X
- Other Apps
Make sure to add the dependency - implementation ( "androidx.navigation:navigation-compose:2.4.0-alpha10" ) package com.example.clicktonewactivity import android.content.Context import android.content.Intent import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview. Preview import com.example.clicktonewactivity.ui.theme.ClickToNewActivityTheme import androidx.compose.runtime.remember import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController import androidx.compose.foundation.layout.Column import androidx.compose.material3.Button imp...
How to read Json
- Get link
- X
- Other Apps
data class Entry( val email : String, val name : String) @Composable fun EntryText (entries: Map<String, Entry>) { LazyColumn { items (entries. entries . toList ()) { (_, entry) -> Column { Text ( "Email: ${ entry. email } " ) Text ( "Name: ${ entry. name } " ) Spacer ( modifier = Modifier. height ( 16 . dp )) // Add spacing between entries } } } } @Composable fun DisplayJsonEntries () { val gson = Gson() // Replace "path/to/your/file.json" with the actual path to your JSON file val jsonFile = File( "/storage/emulated/0/Android/data/com.example.jsonparsing/files/form_data.json" ) val jsonString = jsonFile. readText () // Parse JSON string to a map where keys are entry IDs and values are Entry objects val entries: Map<String, Entry> = gson.fromJson(jsonString, object : TypeToken<Map<String, Entry>>() ...
- Get link
- X
- Other Apps
package com.example.jsonparsing import android.app.Notification import android.os.Bundle import android.provider.CalendarContract.Colors import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.annotation. RequiresApi import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime. Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview. Preview import com.example.jsonparsing.ui.theme.JsonParsingTheme import android.app.NotificationChannel i...